Ver Fonte

Fix TypeError in emoji insert function (#257)

In Chrome, text nodes are not "real" nodes, so they don't have a
`tagName` property.
Danilo Bargen há 8 anos atrás
pai
commit
9720257bd0
1 ficheiros alterados com 4 adições e 2 exclusões
  1. 4 2
      src/directives/compose_area.ts

+ 4 - 2
src/directives/compose_area.ts

@@ -437,8 +437,10 @@ export default [
 
                     // In Chrome in right-to-left mode, our content editable
                     // area may contain a DIV element.
-                    const nestedDiv = composeDiv[0].childNodes.length === 1
-                        && composeDiv[0].childNodes[0].tagName.toLowerCase() === 'div';
+                    const childNodes = composeDiv[0].childNodes;
+                    const nestedDiv = childNodes.length === 1
+                        && childNodes[0].tagName !== undefined
+                        && childNodes[0].tagName.toLowerCase() === 'div';
                     let contentElement;
                     if (nestedDiv === true) {
                         contentElement = composeDiv[0].childNodes[0];