error getting attribute spans even though attributes exist on malformed html
I'm parsing this with quirks = true as document, and then trying to find the attributeSpans when the attributes map isn't empty.
This is the html:
<button attr<="value"></button>
this is the code:
element.attributes.forEach((name, String value) {
if (name is String) {
String lowerName = name.toLowerCase();
int nameOffset = element.attributeSpans[lowerName].start.offset;
and this is the error:
type 'ParseErrorToken' is not a subtype of type 'StartTagToken' in type cast where\n ParseErrorToken is from package:html/src/token.dart\n StartTagToken is from package:html/src/token.dart\n\n#0 Object._as (dart:core-patch/object_patch.dart:74)\n#1 Node._ensureAttributeSpans (package:html/dom.dart:286)\n#2 Node.attributeSpans (package:html/dom.dart:173)\n#3 HtmlTreeConverter._convertAttributes.<anonymous closure> (package:angular2_analyzer_plugin/src/resolver.dart:278)
At the time of error in the debugger
$ p attributes.length
= 1
$ p attributes['attr<']
= 'value'
$ p sourceSpan.text
= '<button attr<="value">'
and the current token is
Token _current = ParseErrorToken { ⊟
FileSpan span = _FileSpan { ⊟
final SourceFile file = SourceFile { ⊞ }
final int _start = 0
final int _end = 13
}
StringBuffer _buffer = null
String _string = 'invalid-character-in-attribute-name'
Map messageParams = null
}
Ick. I wonder if the HTML parser will even be usable for this project.
/cc @jonahwilliams, who is working on the new template parser.