Browse Source

Update parser

pull/36/head
Artur Arseniev 10 years ago
parent
commit
fb3d95175e
  1. 1
      index.html
  2. 3
      src/parser/model/ParserHtml.js
  3. 13
      test/specs/parser/model/ParserHtml.js

1
index.html

@ -16,7 +16,6 @@
<header class="header-banner"> <header class="header-banner">
<div class="container-width"> <div class="container-width">
<div class="logo-container"> <div class="logo-container">
<div></div>
<div class="logo">GrapesJS</div> <div class="logo">GrapesJS</div>
</div> </div>
<nav class="navbar"> <nav class="navbar">

3
src/parser/model/ParserHtml.js

@ -101,7 +101,8 @@ define(function(require) {
// From: <div> <span>TEST</span> </div> <-- span is text type // From: <div> <span>TEST</span> </div> <-- span is text type
// TO: <div> TEST </div> <-- div become text type // TO: <div> TEST </div> <-- div become text type
// With 'nodeChild > 1' I know that nodes were merged // 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.type = 'text';
model.content = parsed[0].content; model.content = parsed[0].content;
}else }else

13
test/specs/parser/model/ParserHtml.js

@ -235,6 +235,19 @@ define([path + 'model/ParserHtml', path + 'model/ParserCss'],
res.css.should.deep.equal(resCss); res.css.should.deep.equal(resCss);
}); });
it('Parse nested div with text and spaces', function() {
var str = '<div> <p>TestText</p> </div>';
var result = {
tagName: 'div',
components: [{
tagName: 'p',
content: 'TestText',
type: 'text',
}],
};
obj.parse(str).html.should.deep.equal(result);
});
}); });
} }

Loading…
Cancel
Save