From 8254ff82e19d41b2a66a4549165b924084ed6a52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 9 Jul 2013 17:31:43 +0200 Subject: [PATCH] Fixing white space handling --- modules/documentCanvas/canvas/canvas.js | 3 +++ modules/documentCanvas/canvas/canvas.test3.js | 1 + 2 files changed, 4 insertions(+) diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index ba7daef..6131e4e 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -53,7 +53,10 @@ $.extend(Canvas.prototype, { + (endSpace && (spanParent || spanAfter) ? ' ' : ''); } else { + var oldLength = this.data.length; this.data = $.trim(this.data); + if(this.data.length === 0 && oldLength > 0) + this.data = ' '; } }); diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 5aa4aad..77b3b19 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -162,6 +162,7 @@ describe('Canvas', function() { var c = canvas.fromXML('
'); expect(c.doc().children().length).to.equal(1); expect(c.doc().children()[0]).to.be.instanceOf(documentElement.DocumentTextElement); + expect(c.doc().children()[0].getText()).to.equal(' '); }); it('ignores white space surrounding block elements', function() { var c = canvas.fromXML('
'); -- 2.20.1