Skip to content

Commit

Permalink
correctly parse HTML4 nested inline elements (#861)
Browse files Browse the repository at this point in the history
fixes #857
  • Loading branch information
alexlamsl authored Oct 17, 2017
1 parent e0108f9 commit 9a45eb4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/htmlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function HTMLParser(html, handler) {
parseEndTag('', lastTag);
}

if (!handler.html5) {
if (!handler.html5 && !inline(tagName)) {
while (lastTag && inline(lastTag)) {
parseEndTag('', lastTag);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/minifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,16 @@ QUnit.test('custom components', function(assert) {
assert.equal(minify(input), output);
});

QUnit.test('HTML4: anchor with inline elements', function(assert) {
var input = '<a href="#"><span>Well, look at me! I\'m a span!</span></a>';
assert.equal(minify(input, { html5: false }), input);
});

QUnit.test('HTML5: anchor with inline elements', function(assert) {
var input = '<a href="#"><span>Well, look at me! I\'m a span!</span></a>';
assert.equal(minify(input, { html5: true }), input);
});

QUnit.test('HTML4: anchor with block elements', function(assert) {
var input = '<a href="#"><div>Well, look at me! I\'m a div!</div></a>';
var output = '<a href="#"></a><div>Well, look at me! I\'m a div!</div>';
Expand Down

0 comments on commit 9a45eb4

Please sign in to comment.