Skip to content

Commit

Permalink
Ignore duplicate spans when parsing
Browse files Browse the repository at this point in the history
Fixes #56
  • Loading branch information
kevmoo committed Jan 9, 2018
1 parent 82bea83 commit f061a0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/dom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ abstract class Node {
generateSpans: true, attributeSpans: true);

tokenizer.moveNext();

while (tokenizer.current is ParseErrorToken) {
tokenizer.moveNext();
}
var token = tokenizer.current as StartTagToken;

if (token.attributeSpans == null) return; // no attributes
Expand Down
7 changes: 7 additions & 0 deletions test/parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:html/dom.dart';
import 'package:html/parser.dart';
import 'package:html/parser_console.dart' as parser_console;
import 'package:html/src/inputstream.dart' as inputstream;
import 'package:source_span/source_span.dart';
import 'support.dart';

// Run the parse error checks
Expand Down Expand Up @@ -71,6 +72,12 @@ void runParserTest(
}

void main() {
test('ignore duplicate attributes when parsing', () {
var dom = parse('<div duplicate duplicate>', generateSpans: true);
expect(dom.querySelector('div').attributeSpans,
{'duplicate': new isInstanceOf<FileSpan>()});
});

test('dart:io', () {
// ensure IO support is unregistered
expect(inputstream.consoleSupport,
Expand Down

0 comments on commit f061a0e

Please sign in to comment.