dint-dev / universal_html

Cross-platform 'dart:html'.
https://pub.dev/packages/universal_html
Apache License 2.0
201 stars 63 forks source link

Failed to execute "node" on "setAttribute": "[class]" is not a valid attribute name. #15

Closed docaohuynh closed 4 years ago

docaohuynh commented 4 years ago

I have got error like this

Unhandled exception:
InvalidCharacterError: Failed to execute "node" on "setAttribute": "[class]" is not a valid attribute name.
#0      Element.setAttributeNS (package:universal_html/src/html/dom/element.dart:2123:7)
#1      Element.setAttribute (package:universal_html/src/html/dom/element.dart:2114:5)
#2      _HtmlParser._newNodeFrom.<anonymous closure> (package:universal_html/src/driver/dom_parser_driver.dart:239:20)
#3      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
#4      _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:235:25)
#5      _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#6      _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#7      _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#8      _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#9      _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#10     _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#11     _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#12     _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#13     _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:248:23)
#14     _HtmlParser._newNodeFrom (package:universal_html/src/driver/dom_parser_driver.dart:283:27)
#15     DomParserDriver.parseHtml (package:universal_html/src/driver/dom_parser_driver.dart:159:23)
#16     DomParserDriver.parseDocument (package:universal_html/src/driver/dom_parser_driver.dart:53:16)
#17     DomParserDriver.parseHtmlFromAnything (package:universal_html/src/driver/dom_parser_driver.dart:128:22)
#18     HtmlDriver.setDocumentFromContent (package:universal_html/src/driver/html_driver.dart:202:38)
#19     HtmlDriver.setDocumentFromUri (package:universal_html/src/driver/html_driver.dart:221:5)
<asynchronous suspension>
#20     CrawlerDictionary.getCambirdge (package:ielts_eccyl/src/utils/crawler_dictionary.dart:32:18)
#21     main (package:ielts_eccyl/main_test.dart:4:23)
#22     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

With my code

final driver = new HtmlDriver(userAgent: UserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36'));
    var url = 'https://dictionary.cambridge.org/vi/dictionary/english-vietnamese/available';
    print(url);
    await driver.setDocumentFromUri(Uri.parse(url));
    final camEv =  driver.document.querySelectorAll('.english-vietnamese');
terrier989 commented 4 years ago

Thanks for the bug report! I'll look at this.

terrier989 commented 4 years ago

Version 1.1.18 fixes this.