html-parser
Advanced tools
Comparing version 0.6.0 to 0.6.1
{ | ||
"name": "html-parser", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "HTML/XML parser with less explosions", | ||
@@ -5,0 +5,0 @@ "keywords": [ "html", "xml", "parser", "explosion" ], |
@@ -75,4 +75,8 @@ var parseContext = require('./context'); | ||
context.read(match[0].length); | ||
context.callbacks.cdata(match[1]); | ||
context.callbacks.closeElement(match[2]); | ||
if (match[1]) { | ||
context.callbacks.cdata(match[1]); | ||
} | ||
if (match[2]) { | ||
context.callbacks.closeElement(match[2]); | ||
} | ||
} | ||
@@ -79,0 +83,0 @@ |
@@ -206,2 +206,43 @@ var should = require('should'); | ||
}); | ||
it('should not parse cdata or close element if script tag is unclosed', function() { | ||
var closeCount = 0, openCount = 0, cdataCount = 0; | ||
helpers.parseString('<script>', { | ||
openElement: function(name) { | ||
name.should.equal('script'); | ||
openCount++; | ||
}, | ||
cdata: function(value) { | ||
cdataCount++; | ||
}, | ||
closeElement: function(name) { | ||
closeCount++; | ||
} | ||
}); | ||
closeCount.should.equal(0); | ||
cdataCount.should.equal(0); | ||
openCount.should.equal(1); | ||
}); | ||
it('should not parse cdata if script tag is empty', function() { | ||
var closeCount = 0, openCount = 0, cdataCount = 0; | ||
helpers.parseString('<script></script>', { | ||
openElement: function(name) { | ||
name.should.equal('script'); | ||
openCount++; | ||
}, | ||
cdata: function(value) { | ||
cdataCount++; | ||
}, | ||
closeElement: function(name) { | ||
name.should.equal('script'); | ||
closeCount++; | ||
} | ||
}); | ||
closeCount.should.equal(1); | ||
cdataCount.should.equal(0); | ||
openCount.should.equal(1); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
71332
1328