From 7d2e12c3dd90b3271db4d4a62723f8e6d1cdda7d Mon Sep 17 00:00:00 2001 From: arrix Date: Fri, 2 Aug 2013 10:11:07 +0800 Subject: [PATCH 1/2] added test case for #251 inline text in top element --- .gitignore | 3 ++- tests/cases/child-textnodes.html | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/cases/child-textnodes.html diff --git a/.gitignore b/.gitignore index 72f9d48..cd47245 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ server.js chromedriver.log *.baseline *.iml -.idea/ \ No newline at end of file +.idea/ +.DS_Store diff --git a/tests/cases/child-textnodes.html b/tests/cases/child-textnodes.html new file mode 100644 index 0000000..ea5cafe --- /dev/null +++ b/tests/cases/child-textnodes.html @@ -0,0 +1,22 @@ + + + + Inline text in the top element + + + + + + + Some inline text followed by text in span followed by more inline text. +

Then a block level element.

+ Then more inline text. + + From fd888bde8d489fc03060161c3483f302a8268b25 Mon Sep 17 00:00:00 2001 From: arrix Date: Fri, 2 Aug 2013 14:36:42 +0800 Subject: [PATCH 2/2] fixes #251. inline text in top element --- src/Parse.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Parse.js b/src/Parse.js index 60f6147..ef81f6a 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -1135,8 +1135,12 @@ _html2canvas.Parse = function (images, options) { svgDOMRender(document.documentElement, stack); } - Array.prototype.slice.call(element.children, 0).forEach(function(childElement) { - parseElement(childElement, stack); + _html2canvas.Util.Children(element).forEach(function(node) { + if (node.nodeType === 1) { + parseElement(node, stack); + } else if (node.nodeType === 3) { + renderText(element, node, stack); + } }); stack.backgroundColor = getCSS(document.documentElement, "backgroundColor");