diff --git a/src/parser.js b/src/parser.js index ddc34d8..180ed8f 100644 --- a/src/parser.js +++ b/src/parser.js @@ -134,9 +134,9 @@ function callbackText(context) { function parseNext(context) { var current = context.current, buffer = current; if (current == '<') { - buffer += context.readUntilNonWhitespace(); + buffer += context.read(); if (context.current === '/') { - buffer += context.readUntilNonWhitespace(); + buffer += context.read(); if (nameRegex.test(context.current)) { callbackText(context); parseEndElement(context); diff --git a/tests/malformed-tests.js b/tests/malformed-tests.js index 5165396..e478cb4 100644 --- a/tests/malformed-tests.js +++ b/tests/malformed-tests.js @@ -19,21 +19,21 @@ describe('Malformed HTML', function() { textCount.should.equal(1); }); - it('< followed by a letter without a following > is still a tag', function() { + it('< followed by whitespace is not a tag', function() { var openCount = 0, textCount = 0; - helpers.parseString('< foo', { + helpers.parseString('< foo>', { openElement: function(name) { - name.should.equal('foo'); openCount++; }, text: function(value) { + value.should.equal('< foo>'); textCount++; } }); - openCount.should.equal(1); - textCount.should.equal(0); + openCount.should.equal(0); + textCount.should.equal(1); }); it('< followed by ! but not cdata or comment should be a text node', function() { @@ -63,13 +63,13 @@ describe('Malformed HTML', function() { it('', { closeElement: function(name) { closeCount++; }, text: function(value) { - value.should.equal(''); textCount++; } }); diff --git a/tests/open-and-close-tag-tests.js b/tests/open-and-close-tag-tests.js index 058350b..41e1127 100644 --- a/tests/open-and-close-tag-tests.js +++ b/tests/open-and-close-tag-tests.js @@ -67,7 +67,7 @@ describe('opening and closing tags', function() { it('tag names with weird whitespace', function() { var openCount = 0, closeCount = 0; - helpers.parseString('< \n foo\n>', { + helpers.parseString('', { openElement: function(name) { name.should.equal('foo'); openCount++;