@@ -274,7 +274,9 @@ _html2canvas.Parse = function (images, options) {
274274
275275 text_align = text_align . replace ( [ "-webkit-auto" ] , [ "auto" ] ) ;
276276
277- renderList = ( ! options . letterRendering && / ^ ( l e f t | r i g h t | j u s t i f y | a u t o ) $ / . test ( text_align ) && noLetterSpacing ( letter_spacing ) ) ? textNode . nodeValue . split ( / ( \b | ) / ) : textNode . nodeValue . split ( "" ) ;
277+ renderList = ( ! options . letterRendering && / ^ ( l e f t | r i g h t | j u s t i f y | a u t o ) $ / . test ( text_align ) && noLetterSpacing ( letter_spacing ) )
278+ ? textNode . nodeValue . split ( / ( \b | ) / )
279+ : textNode . nodeValue . split ( "" ) ;
278280
279281 metrics = setTextVariables ( ctx , el , text_decoration , color ) ;
280282 oldTextNode = textNode ;
@@ -307,7 +309,7 @@ _html2canvas.Parse = function (images, options) {
307309 // it isn't supported, so let's wrap it inside an element instead and get the bounds there
308310
309311 // IE 9 bug
310- if ( typeof oldTextNode . nodeValue !== "string" ) {
312+ if ( ! oldTextNode || typeof oldTextNode . nodeValue !== "string" ) {
311313 continue ;
312314 }
313315
@@ -326,7 +328,6 @@ _html2canvas.Parse = function (images, options) {
326328
327329 oldTextNode = newTextNode ;
328330 parent . replaceChild ( backupText , wrapElement ) ;
329-
330331 }
331332
332333 if ( textValue !== null ) {
@@ -1002,25 +1003,22 @@ _html2canvas.Parse = function (images, options) {
10021003
10031004 // skip hidden elements and their children
10041005 if ( getCSS ( el , 'display' ) !== "none" && getCSS ( el , 'visibility' ) !== "hidden" && ! el . hasAttribute ( "data-html2canvas-ignore" ) ) {
1005-
10061006 stack = renderElement ( el , stack ) || stack ;
1007-
10081007 ctx = stack . ctx ;
10091008
1010- if ( ! ignoreElementsRegExp . test ( el . nodeName ) ) {
1011- var elementChildren = _html2canvas . Util . Children ( el ) ,
1009+ if ( ! ignoreElementsRegExp . test ( el . nodeName ) ) {
1010+ var elementChildren = _html2canvas . Util . Children ( el ) ,
10121011 i ,
10131012 node ,
10141013 childrenLen ;
1014+
10151015 for ( i = 0 , childrenLen = elementChildren . length ; i < childrenLen ; i += 1 ) {
10161016 node = elementChildren [ i ] ;
1017-
1018- if ( node . nodeType === 1 ) {
1017+ if ( node . nodeType === 1 ) {
10191018 parseElement ( node , stack ) ;
1020- } else if ( node . nodeType === 3 ) {
1019+ } else if ( node . nodeType === 3 ) {
10211020 renderText ( el , node , stack ) ;
10221021 }
1023-
10241022 }
10251023
10261024 }
@@ -1081,7 +1079,7 @@ _html2canvas.Parse = function (images, options) {
10811079
10821080 }
10831081
1084- parseDOM ( body ) ;
1082+ parseDOM ( body ) ;
10851083 img . src = [
10861084 "data:image/svg+xml," ,
10871085 "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='" + size . width + "' height='" + size . height + "'>" ,
@@ -1093,14 +1091,11 @@ _html2canvas.Parse = function (images, options) {
10931091 "</svg>"
10941092 ] . join ( "" ) ;
10951093
1096-
1097-
1098-
10991094 img . onload = function ( ) {
11001095 stack . svgRender = img ;
11011096 } ;
11021097
1103- } ) ( document . documentElement ) ;
1098+ } ) ( document . documentElement ) ;
11041099
11051100 }
11061101
@@ -1110,8 +1105,7 @@ _html2canvas.Parse = function (images, options) {
11101105 parseElement ( children [ i ] , stack ) ;
11111106 }
11121107
1113-
1114- stack . backgroundColor = getCSS ( document . documentElement , "backgroundColor" ) ;
1108+ stack . backgroundColor = getCSS ( document . documentElement , "backgroundColor" ) ;
11151109
11161110 return stack ;
11171111
0 commit comments