html-parse-stringify2
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -39,7 +39,5 @@ /*jshint -W030 */ | ||
} | ||
// check if this is a comment tag. if so, just return. | ||
if (tag.indexOf('<!--') === 0) { | ||
return; | ||
} | ||
var isOpen = tag.charAt(1) !== '/'; | ||
var isComment = tag.indexOf('<!--') === 0; | ||
var start = index + tag.length; | ||
@@ -49,3 +47,3 @@ var nextChar = html.charAt(start); | ||
if (isOpen) { | ||
if (isOpen && !isComment) { | ||
level++; | ||
@@ -79,4 +77,6 @@ | ||
if (!isOpen || current.voidElement) { | ||
level--; | ||
if (isComment || !isOpen || current.voidElement) { | ||
if (!isComment) { | ||
level--; | ||
} | ||
if (!inComponent && nextChar !== '<' && nextChar) { | ||
@@ -83,0 +83,0 @@ // trailing text node |
{ | ||
"name": "html-parse-stringify2", | ||
"description": "Parses well-formed HTML (meaning all tags closed) into an AST and back. quickly.", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "Ray Di Ciaccio <ray.diciaccio@gmail.com>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -388,3 +388,3 @@ /* global console */ | ||
html = '<div>Hi <!-- I\'m a nested comment! with a <span></span> --></div><span><!--test--></span>'; | ||
html = '<div>Hi <!-- I\'m a nested comment! with a <span></span> -->there<strong>!</strong></div><span><!--test--></span>'; | ||
parsed = HTML.parse(html); | ||
@@ -397,3 +397,11 @@ t.deepEqual(parsed, [{ | ||
children: [ | ||
{ type: 'text', content: 'Hi '} | ||
{ type: 'text', content: 'Hi '}, | ||
{ type: 'text', content: 'there'}, | ||
{ | ||
type: 'tag', | ||
name: 'strong', | ||
attrs: {}, | ||
voidElement: false, | ||
children: [{ type: 'text', content: '!'}] | ||
} | ||
] | ||
@@ -400,0 +408,0 @@ },{ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28029
647