From 2ee6a5d07d57b868eb91c59cb633732771f08b77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 5 Jul 2013 16:34:24 +0200 Subject: [PATCH] fix --- modules/documentCanvas/canvas/canvas.test3.js | 6 ++++++ modules/documentCanvas/canvas/documentElement.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 4ed6ce1..8f779d3 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -38,6 +38,12 @@ describe('Canvas', function() { children = c.doc().children(); expect(children.length).to.equal(1); expect(children[0]).to.be.instanceOf(documentElement.DocumentNodeElement); + + c = canvas.fromXML('
'), + children = c.doc().children(); + expect(children.length).to.equal(2); + expect(children[0]).to.be.instanceOf(documentElement.DocumentNodeElement); + expect(children[1]).to.be.instanceOf(documentElement.DocumentNodeElement); }); it('reports text nodes', function() { var c = canvas.fromXML('
Alice
'), diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index ed5613e..637da5f 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -22,7 +22,7 @@ $.extend(DocumentElement.prototype, { var elementContent = this.$element.contents(); elementContent.each(function(idx) { var element = documentElementFromHTMLElement(this); - if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && $.trim($(this).text()) === '') + if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && (element instanceof DocumentTextElement) && $.trim($(this).text()) === '') return true; if(idx > 0 && element instanceof DocumentTextElement) { if(toret[toret.length-1] instanceof DocumentNodeElement && $.trim($(this).text()) === '') -- 2.20.1