diff --git a/index.html b/index.html index 98034a90b..6002adc8b 100755 --- a/index.html +++ b/index.html @@ -16,7 +16,6 @@ - GrapesJS diff --git a/src/parser/model/ParserHtml.js b/src/parser/model/ParserHtml.js index 735a4f17c..8167701bb 100644 --- a/src/parser/model/ParserHtml.js +++ b/src/parser/model/ParserHtml.js @@ -101,7 +101,8 @@ define(function(require) { // From: TEST <-- span is text type // TO: TEST <-- div become text type // With 'nodeChild > 1' I know that nodes were merged - if(parsed.length == 1 && parsed[0].type == 'text' && nodeChild > 1){ + if(parsed.length == 1 && parsed[0].type == 'text' && + nodeChild > 1 && parsed[0].tagName == TEXT_NODE){ model.type = 'text'; model.content = parsed[0].content; }else diff --git a/test/specs/parser/model/ParserHtml.js b/test/specs/parser/model/ParserHtml.js index 40309f775..4a8b647ac 100644 --- a/test/specs/parser/model/ParserHtml.js +++ b/test/specs/parser/model/ParserHtml.js @@ -235,6 +235,19 @@ define([path + 'model/ParserHtml', path + 'model/ParserCss'], res.css.should.deep.equal(resCss); }); + it('Parse nested div with text and spaces', function() { + var str = ' TestText '; + var result = { + tagName: 'div', + components: [{ + tagName: 'p', + content: 'TestText', + type: 'text', + }], + }; + obj.parse(str).html.should.deep.equal(result); + }); + }); }
TestText