Enable and fix a number of lints (#82)
diff --git a/.travis.yml b/.travis.yml
index 2750414..714aa86 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,7 @@
dart_task:
- test: -p vm
- test: -p chrome,firefox
- - dartanalyzer
+ - dartanalyzer: --fatal-warnings --fatal-infos .
matrix:
include:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ee47f53..321fd3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.13.4
+
+* Require Dart 2.0 stable.
+
## 0.13.3+3
* Fix missing_return analyzer errors in `processStartTag` and `processEndTag`
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 2ba6e21..9141625 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,50 +1,65 @@
+include: package:pedantic/analysis_options.yaml
analyzer:
errors:
+ unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
- override_on_non_overriding_method: error
linter:
rules:
- # Errors
- - avoid_empty_else
- - await_only_futures
- #- comment_references
- - control_flow_in_finally
- - empty_statements
- - hash_and_equals
- - iterable_contains_unrelated_type
- - no_duplicate_case_values
- - test_types_in_equals
- - throw_in_finally
- - unawaited_futures
- - unnecessary_statements
- - unrelated_type_equality_checks
- - valid_regexps
-
- # Style
#- annotate_overrides
#- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- - avoid_return_types_on_setters
+ - avoid_null_checks_in_equality_operators
+ - avoid_relative_lib_imports
- avoid_returning_null
- avoid_unused_constructor_parameters
+ - await_only_futures
- camel_case_types
+ - cancel_subscriptions
+ #- comment_references
+ # See https://github.com/dart-lang/logging/issues/43
+ #- constant_identifier_names
+ - control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
+ - empty_statements
+ - hash_and_equals
+ - implementation_imports
+ #- invariant_booleans
+ - iterable_contains_unrelated_type
- library_names
- library_prefixes
- #- non_constant_identifier_names
+ - list_remove_unrelated_type
+ - no_adjacent_strings_in_list
+ - non_constant_identifier_names
+ #- omit_local_variable_types
+ - only_throw_errors
+ - overridden_fields
+ - package_api_docs
+ - package_names
+ - package_prefixed_library_names
+ - prefer_adjacent_string_concatenation
+ #- prefer_collection_literals
#- prefer_conditional_assignment
+ - prefer_const_constructors
- prefer_final_fields
- - prefer_is_empty
- - prefer_is_not_empty
+ - prefer_initializing_formals
+ #- prefer_interpolation_to_compose_strings
+ #- prefer_single_quotes
#- prefer_typing_uninitialized_variables
- - recursive_getters
- #- slash_for_doc_comments
+ - slash_for_doc_comments
+ - test_types_in_equals
+ - super_goes_last
+ - test_types_in_equals
+ - throw_in_finally
- type_init_formals
#- unnecessary_brace_in_string_interps
+ - unnecessary_const
- unnecessary_getters_setters
- unnecessary_lambdas
+ - unnecessary_new
- unnecessary_null_aware_assignments
+ - unnecessary_statements
+ - unnecessary_this
diff --git a/lib/dom.dart b/lib/dom.dart
index 2e57f64..1a6e7ed 100644
--- a/lib/dom.dart
+++ b/lib/dom.dart
@@ -145,11 +145,11 @@
///
/// Note that attribute order needs to be stable for serialization, so we use
/// a LinkedHashMap. Each key is a [String] or [AttributeName].
- LinkedHashMap<dynamic, String> attributes = new LinkedHashMap();
+ LinkedHashMap<dynamic, String> attributes = LinkedHashMap();
/// A list of child nodes of the current node. This must
/// include all elements but not necessarily other node types.
- final NodeList nodes = new NodeList._();
+ final NodeList nodes = NodeList._();
List<Element> _elements;
@@ -186,7 +186,7 @@
List<Element> get children {
if (_elements == null) {
- _elements = new FilteredElementList(this);
+ _elements = FilteredElementList(this);
}
return _elements;
}
@@ -201,13 +201,13 @@
// http://domparsing.spec.whatwg.org/#extensions-to-the-element-interface
String get _outerHtml {
- var str = new StringBuffer();
+ var str = StringBuffer();
_addOuterHtml(str);
return str.toString();
}
String get _innerHtml {
- var str = new StringBuffer();
+ var str = StringBuffer();
_addInnerHtml(str);
return str.toString();
}
@@ -249,7 +249,7 @@
/// Replaces this node with another node.
Node replaceWith(Node otherNode) {
if (parentNode == null) {
- throw new UnsupportedError('Node must have a parent to replace it.');
+ throw UnsupportedError('Node must have a parent to replace it.');
}
parentNode.nodes[parentNode.nodes.indexOf(this)] = otherNode;
return this;
@@ -275,12 +275,12 @@
void _ensureAttributeSpans() {
if (_attributeSpans != null) return;
- _attributeSpans = new LinkedHashMap<dynamic, FileSpan>();
- _attributeValueSpans = new LinkedHashMap<dynamic, FileSpan>();
+ _attributeSpans = LinkedHashMap<dynamic, FileSpan>();
+ _attributeValueSpans = LinkedHashMap<dynamic, FileSpan>();
if (sourceSpan == null) return;
- var tokenizer = new HtmlTokenizer(sourceSpan.text,
+ var tokenizer = HtmlTokenizer(sourceSpan.text,
generateSpans: true, attributeSpans: true);
tokenizer.moveNext();
@@ -333,18 +333,18 @@
void _addOuterHtml(StringBuffer str) => _addInnerHtml(str);
- Document clone(bool deep) => _clone(new Document(), deep);
+ Document clone(bool deep) => _clone(Document(), deep);
- Element createElement(String tag) => new Element.tag(tag);
+ Element createElement(String tag) => Element.tag(tag);
// TODO(jmesserly): this is only a partial implementation of:
// http://dom.spec.whatwg.org/#dom-document-createelementns
Element createElementNS(String namespaceUri, String tag) {
if (namespaceUri == '') namespaceUri = null;
- return new Element._(tag, namespaceUri);
+ return Element._(tag, namespaceUri);
}
- DocumentFragment createDocumentFragment() => new DocumentFragment();
+ DocumentFragment createDocumentFragment() => DocumentFragment();
}
class DocumentFragment extends Node with _ParentNode, _NonElementParentNode {
@@ -363,7 +363,7 @@
String toString() => "#document-fragment";
- DocumentFragment clone(bool deep) => _clone(new DocumentFragment(), deep);
+ DocumentFragment clone(bool deep) => _clone(DocumentFragment(), deep);
void _addOuterHtml(StringBuffer str) => _addInnerHtml(str);
@@ -376,10 +376,7 @@
final String publicId;
final String systemId;
- DocumentType(String name, this.publicId, this.systemId)
- // Note: once Node.tagName is removed, don't pass "name" to super
- : name = name,
- super._();
+ DocumentType(this.name, this.publicId, this.systemId) : super._();
int get nodeType => Node.DOCUMENT_TYPE_NODE;
@@ -399,7 +396,7 @@
str.write(toString());
}
- DocumentType clone(bool deep) => new DocumentType(name, publicId, systemId);
+ DocumentType clone(bool deep) => DocumentType(name, publicId, systemId);
}
class Text extends Node {
@@ -423,10 +420,10 @@
void _addOuterHtml(StringBuffer str) => writeTextNodeAsHtml(str, this);
- Text clone(bool deep) => new Text(data);
+ Text clone(bool deep) => Text(data);
void appendData(String data) {
- if (_data is! StringBuffer) _data = new StringBuffer(_data);
+ if (_data is! StringBuffer) _data = StringBuffer(_data);
StringBuffer sb = _data;
sb.write(data);
}
@@ -457,9 +454,9 @@
: namespaceUri = Namespaces.html,
super._();
- static final _START_TAG_REGEXP = new RegExp('<(\\w+)');
+ static final _startTagRegexp = RegExp('<(\\w+)');
- static final _CUSTOM_PARENT_TAG_MAP = const {
+ static final _customParentTagMap = const {
'body': 'html',
'head': 'html',
'caption': 'table',
@@ -487,11 +484,11 @@
// 4) Detatch the created element from its dummy parent.
String parentTag = 'div';
String tag;
- final match = _START_TAG_REGEXP.firstMatch(html);
+ final match = _startTagRegexp.firstMatch(html);
if (match != null) {
tag = match.group(1).toLowerCase();
- if (_CUSTOM_PARENT_TAG_MAP.containsKey(tag)) {
- parentTag = _CUSTOM_PARENT_TAG_MAP[tag];
+ if (_customParentTagMap.containsKey(tag)) {
+ parentTag = _customParentTagMap[tag];
}
}
@@ -503,7 +500,7 @@
// You'll always get a head and a body when starting from html.
element = fragment.children[tag == 'head' ? 0 : 1];
} else {
- throw new ArgumentError('HTML had ${fragment.children.length} '
+ throw ArgumentError('HTML had ${fragment.children.length} '
'top level elements but 1 expected');
}
element.remove();
@@ -613,8 +610,8 @@
}
Element clone(bool deep) {
- var result = new Element._(localName, namespaceUri)
- ..attributes = new LinkedHashMap.from(attributes);
+ var result = Element._(localName, namespaceUri)
+ ..attributes = LinkedHashMap.from(attributes);
return _clone(result, deep);
}
@@ -638,17 +635,15 @@
attributes['class'] = '$value';
}
- /**
- * The set of CSS classes applied to this element.
- *
- * This set makes it easy to add, remove or toggle the classes applied to
- * this element.
- *
- * element.classes.add('selected');
- * element.classes.toggle('isOnline');
- * element.classes.remove('selected');
- */
- CssClassSet get classes => new ElementCssClassSet(this);
+ /// The set of CSS classes applied to this element.
+ ///
+ /// This set makes it easy to add, remove or toggle the classes applied to
+ /// this element.
+ ///
+ /// element.classes.add('selected');
+ /// element.classes.toggle('isOnline');
+ /// element.classes.remove('selected');
+ CssClassSet get classes => ElementCssClassSet(this);
}
class Comment extends Node {
@@ -664,11 +659,11 @@
str.write("<!--$data-->");
}
- Comment clone(bool deep) => new Comment(data);
+ Comment clone(bool deep) => Comment(data);
String get text => data;
set text(String value) {
- this.data = value;
+ data = value;
}
}
@@ -744,15 +739,15 @@
// http://code.google.com/p/dart/issues/detail?id=5371
void setRange(int start, int rangeLength, Iterable<Node> from,
[int startFrom = 0]) {
- List<Node> from_ = from as List<Node>;
- if (from_ is NodeList) {
+ List<Node> fromVar = from as List<Node>;
+ if (fromVar is NodeList) {
// Note: this is presumed to make a copy
- from_ = from_.sublist(startFrom, startFrom + rangeLength);
+ fromVar = fromVar.sublist(startFrom, startFrom + rangeLength);
}
// Note: see comment in [addAll]. We need to be careful about the order of
// operations if [from] is also a NodeList.
for (int i = rangeLength - 1; i >= 0; i--) {
- this[start + i] = from_[startFrom + i];
+ this[start + i] = fromVar[startFrom + i];
}
}
@@ -826,7 +821,7 @@
// TODO(nweiz): we don't always need to create a new list. For example
// forEach, every, any, ... could directly work on the _childNodes.
List<Element> get _filtered =>
- new List<Element>.from(_childNodes.where((n) => n is Element));
+ List<Element>.from(_childNodes.where((n) => n is Element));
void forEach(void f(Element element)) {
_filtered.forEach(f);
@@ -837,11 +832,11 @@
}
set length(int newLength) {
- final len = this.length;
+ final len = length;
if (newLength >= len) {
return;
} else if (newLength < 0) {
- throw new ArgumentError("Invalid list length");
+ throw ArgumentError("Invalid list length");
}
removeRange(newLength, len);
@@ -866,20 +861,20 @@
Iterable<Element> get reversed => _filtered.reversed;
void sort([int compare(Element a, Element b)]) {
- throw new UnsupportedError('TODO(jacobr): should we impl?');
+ throw UnsupportedError('TODO(jacobr): should we impl?');
}
void setRange(int start, int end, Iterable<Element> iterable,
[int skipCount = 0]) {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
void fillRange(int start, int end, [Element fillValue]) {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
void replaceRange(int start, int end, Iterable<Element> iterable) {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
void removeRange(int start, int end) {
@@ -893,7 +888,7 @@
}
Element removeLast() {
- final result = this.last;
+ final result = last;
if (result != null) {
result.remove();
}
@@ -940,9 +935,9 @@
bool every(bool f(Element element)) => _filtered.every(f);
bool any(bool f(Element element)) => _filtered.any(f);
- List<Element> toList({bool growable: true}) =>
- new List<Element>.from(this, growable: growable);
- Set<Element> toSet() => new Set<Element>.from(this);
+ List<Element> toList({bool growable = true}) =>
+ List<Element>.from(this, growable: growable);
+ Set<Element> toSet() => Set<Element>.from(this);
Element firstWhere(bool test(Element value), {Element orElse()}) {
return _filtered.firstWhere(test, orElse: orElse);
}
@@ -952,7 +947,7 @@
}
Element singleWhere(bool test(Element value), {Element orElse()}) {
- if (orElse != null) throw new UnimplementedError('orElse');
+ if (orElse != null) throw UnimplementedError('orElse');
return _filtered.singleWhere(test);
}
@@ -988,16 +983,15 @@
// http://dom.spec.whatwg.org/#dom-node-textcontent
// For Element and DocumentFragment
-String _getText(Node node) =>
- (new _ConcatTextVisitor()..visit(node)).toString();
+String _getText(Node node) => (_ConcatTextVisitor()..visit(node)).toString();
void _setText(Node node, String value) {
node.nodes.clear();
- node.append(new Text(value));
+ node.append(Text(value));
}
class _ConcatTextVisitor extends TreeVisitor {
- final _str = new StringBuffer();
+ final _str = StringBuffer();
String toString() => _str.toString();
diff --git a/lib/dom_parsing.dart b/lib/dom_parsing.dart
index 3435a81..4fc3707 100644
--- a/lib/dom_parsing.dart
+++ b/lib/dom_parsing.dart
@@ -22,7 +22,7 @@
case Node.DOCUMENT_TYPE_NODE:
return visitDocumentType(node);
default:
- throw new UnsupportedError('DOM node type ${node.nodeType}');
+ throw UnsupportedError('DOM node type ${node.nodeType}');
}
}
@@ -54,7 +54,7 @@
/// displaying the HTML's source code with CSS colors for different parts of the
/// markup. See also [CodeMarkupVisitor].
String htmlToCodeMarkup(Node node) {
- return (new CodeMarkupVisitor()..visit(node)).toString();
+ return (CodeMarkupVisitor()..visit(node)).toString();
}
/// Converts the DOM tree into an HTML string with code markup suitable for
@@ -63,7 +63,7 @@
class CodeMarkupVisitor extends TreeVisitor {
final StringBuffer _str;
- CodeMarkupVisitor() : _str = new StringBuffer();
+ CodeMarkupVisitor() : _str = StringBuffer();
String toString() => _str.toString();
@@ -125,7 +125,7 @@
///
/// [1]: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#serializing-html-fragments
/// [2]: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
-String htmlSerializeEscape(String text, {bool attributeMode: false}) {
+String htmlSerializeEscape(String text, {bool attributeMode = false}) {
// TODO(jmesserly): is it faster to build up a list of codepoints?
// StringBuffer seems cleaner assuming Dart can unbox 1-char strings.
StringBuffer result;
@@ -150,7 +150,7 @@
break;
}
if (replace != null) {
- if (result == null) result = new StringBuffer(text.substring(0, i));
+ if (result == null) result = StringBuffer(text.substring(0, i));
result.write(replace);
} else if (result != null) {
result.write(ch);
diff --git a/lib/parser.dart b/lib/parser.dart
index 2c2c039..3f32178 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -37,8 +37,8 @@
/// can additionally pass [sourceUrl] to indicate where the [input] was
/// extracted from.
Document parse(input,
- {String encoding, bool generateSpans: false, String sourceUrl}) {
- var p = new HtmlParser(input,
+ {String encoding, bool generateSpans = false, String sourceUrl}) {
+ var p = HtmlParser(input,
encoding: encoding, generateSpans: generateSpans, sourceUrl: sourceUrl);
return p.parse();
}
@@ -56,11 +56,11 @@
/// additionally pass [sourceUrl] to indicate where the [input] was extracted
/// from.
DocumentFragment parseFragment(input,
- {String container: "div",
+ {String container = "div",
String encoding,
- bool generateSpans: false,
+ bool generateSpans = false,
String sourceUrl}) {
- var p = new HtmlParser(input,
+ var p = HtmlParser(input,
encoding: encoding, generateSpans: generateSpans, sourceUrl: sourceUrl);
return p.parseFragment(container);
}
@@ -143,18 +143,17 @@
/// DOM will do if you request [Node.outerHTML], for example.
HtmlParser(input,
{String encoding,
- bool parseMeta: true,
- bool lowercaseElementName: true,
- bool lowercaseAttrName: true,
- this.strict: false,
- bool generateSpans: false,
+ bool parseMeta = true,
+ bool lowercaseElementName = true,
+ bool lowercaseAttrName = true,
+ this.strict = false,
+ this.generateSpans = false,
String sourceUrl,
TreeBuilder tree})
- : generateSpans = generateSpans,
- tree = tree != null ? tree : new TreeBuilder(true),
+ : tree = tree != null ? tree : TreeBuilder(true),
tokenizer = (input is HtmlTokenizer
? input
- : new HtmlTokenizer(input,
+ : HtmlTokenizer(input,
encoding: encoding,
parseMeta: parseMeta,
lowercaseElementName: lowercaseElementName,
@@ -162,33 +161,33 @@
generateSpans: generateSpans,
sourceUrl: sourceUrl)) {
tokenizer.parser = this;
- _initialPhase = new InitialPhase(this);
- _beforeHtmlPhase = new BeforeHtmlPhase(this);
- _beforeHeadPhase = new BeforeHeadPhase(this);
- _inHeadPhase = new InHeadPhase(this);
+ _initialPhase = InitialPhase(this);
+ _beforeHtmlPhase = BeforeHtmlPhase(this);
+ _beforeHeadPhase = BeforeHeadPhase(this);
+ _inHeadPhase = InHeadPhase(this);
// TODO(jmesserly): html5lib did not implement the no script parsing mode
// More information here:
// http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#scripting-flag
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#parsing-main-inheadnoscript
// "inHeadNoscript": new InHeadNoScriptPhase(this);
- _afterHeadPhase = new AfterHeadPhase(this);
- _inBodyPhase = new InBodyPhase(this);
- _textPhase = new TextPhase(this);
- _inTablePhase = new InTablePhase(this);
- _inTableTextPhase = new InTableTextPhase(this);
- _inCaptionPhase = new InCaptionPhase(this);
- _inColumnGroupPhase = new InColumnGroupPhase(this);
- _inTableBodyPhase = new InTableBodyPhase(this);
- _inRowPhase = new InRowPhase(this);
- _inCellPhase = new InCellPhase(this);
- _inSelectPhase = new InSelectPhase(this);
- _inSelectInTablePhase = new InSelectInTablePhase(this);
- _inForeignContentPhase = new InForeignContentPhase(this);
- _afterBodyPhase = new AfterBodyPhase(this);
- _inFramesetPhase = new InFramesetPhase(this);
- _afterFramesetPhase = new AfterFramesetPhase(this);
- _afterAfterBodyPhase = new AfterAfterBodyPhase(this);
- _afterAfterFramesetPhase = new AfterAfterFramesetPhase(this);
+ _afterHeadPhase = AfterHeadPhase(this);
+ _inBodyPhase = InBodyPhase(this);
+ _textPhase = TextPhase(this);
+ _inTablePhase = InTablePhase(this);
+ _inTableTextPhase = InTableTextPhase(this);
+ _inCaptionPhase = InCaptionPhase(this);
+ _inColumnGroupPhase = InColumnGroupPhase(this);
+ _inTableBodyPhase = InTableBodyPhase(this);
+ _inRowPhase = InRowPhase(this);
+ _inCellPhase = InCellPhase(this);
+ _inSelectPhase = InSelectPhase(this);
+ _inSelectInTablePhase = InSelectInTablePhase(this);
+ _inForeignContentPhase = InForeignContentPhase(this);
+ _afterBodyPhase = AfterBodyPhase(this);
+ _inFramesetPhase = InFramesetPhase(this);
+ _afterFramesetPhase = AfterFramesetPhase(this);
+ _afterAfterBodyPhase = AfterAfterBodyPhase(this);
+ _afterAfterFramesetPhase = AfterAfterFramesetPhase(this);
}
bool get innerHTMLMode => innerHTML != null;
@@ -205,7 +204,7 @@
/// Pass a [container] to change the type of the containing element.
/// After parsing, [errors] will be populated with parse errors, if any.
DocumentFragment parseFragment([String container = "div"]) {
- if (container == null) throw new ArgumentError('container');
+ if (container == null) throw ArgumentError('container');
innerHTML = container.toLowerCase();
_parse();
return tree.getFragment();
@@ -266,13 +265,13 @@
return enc == "text/html" || enc == "application/xhtml+xml";
} else {
return htmlIntegrationPointElements
- .contains(new Pair(element.namespaceUri, element.localName));
+ .contains(Pair(element.namespaceUri, element.localName));
}
}
bool isMathMLTextIntegrationPoint(Element element) {
return mathmlTextIntegrationPointElements
- .contains(new Pair(element.namespaceUri, element.localName));
+ .contains(Pair(element.namespaceUri, element.localName));
}
bool inForeignContent(Token token, int type) {
@@ -323,29 +322,29 @@
parseError(error.span, error.data, error.messageParams);
newToken = null;
} else {
- Phase phase_ = phase;
+ Phase localPhase = phase;
if (inForeignContent(token, type)) {
- phase_ = _inForeignContentPhase;
+ localPhase = _inForeignContentPhase;
}
switch (type) {
case TokenKind.characters:
- newToken = phase_.processCharacters(newToken);
+ newToken = localPhase.processCharacters(newToken);
break;
case TokenKind.spaceCharacters:
- newToken = phase_.processSpaceCharacters(newToken);
+ newToken = localPhase.processSpaceCharacters(newToken);
break;
case TokenKind.startTag:
- newToken = phase_.processStartTag(newToken);
+ newToken = localPhase.processStartTag(newToken);
break;
case TokenKind.endTag:
- newToken = phase_.processEndTag(newToken);
+ newToken = localPhase.processEndTag(newToken);
break;
case TokenKind.comment:
- newToken = phase_.processComment(newToken);
+ newToken = localPhase.processComment(newToken);
break;
case TokenKind.doctype:
- newToken = phase_.processDoctype(newToken);
+ newToken = localPhase.processDoctype(newToken);
break;
}
}
@@ -385,7 +384,7 @@
span = _lastSpan;
}
- var err = new ParseError(errorcode, span, datavars);
+ var err = ParseError(errorcode, span, datavars);
errors.add(err);
if (strict) throw err;
}
@@ -474,20 +473,18 @@
// TODO(jmesserly): I don't like mixing non-string objects with strings in
// the Node.attributes Map. Is there another solution?
final replacements = const {
- "xlink:actuate":
- const AttributeName("xlink", "actuate", Namespaces.xlink),
- "xlink:arcrole":
- const AttributeName("xlink", "arcrole", Namespaces.xlink),
- "xlink:href": const AttributeName("xlink", "href", Namespaces.xlink),
- "xlink:role": const AttributeName("xlink", "role", Namespaces.xlink),
- "xlink:show": const AttributeName("xlink", "show", Namespaces.xlink),
- "xlink:title": const AttributeName("xlink", "title", Namespaces.xlink),
- "xlink:type": const AttributeName("xlink", "type", Namespaces.xlink),
- "xml:base": const AttributeName("xml", "base", Namespaces.xml),
- "xml:lang": const AttributeName("xml", "lang", Namespaces.xml),
- "xml:space": const AttributeName("xml", "space", Namespaces.xml),
- "xmlns": const AttributeName(null, "xmlns", Namespaces.xmlns),
- "xmlns:xlink": const AttributeName("xmlns", "xlink", Namespaces.xmlns)
+ "xlink:actuate": AttributeName("xlink", "actuate", Namespaces.xlink),
+ "xlink:arcrole": AttributeName("xlink", "arcrole", Namespaces.xlink),
+ "xlink:href": AttributeName("xlink", "href", Namespaces.xlink),
+ "xlink:role": AttributeName("xlink", "role", Namespaces.xlink),
+ "xlink:show": AttributeName("xlink", "show", Namespaces.xlink),
+ "xlink:title": AttributeName("xlink", "title", Namespaces.xlink),
+ "xlink:type": AttributeName("xlink", "type", Namespaces.xlink),
+ "xml:base": AttributeName("xml", "base", Namespaces.xml),
+ "xml:lang": AttributeName("xml", "lang", Namespaces.xml),
+ "xml:space": AttributeName("xml", "space", Namespaces.xml),
+ "xmlns": AttributeName(null, "xmlns", Namespaces.xmlns),
+ "xmlns:xlink": AttributeName("xmlns", "xlink", Namespaces.xmlns)
};
for (var originalName in token.data.keys.toList()) {
@@ -604,12 +601,10 @@
final TreeBuilder tree;
- Phase(HtmlParser parser)
- : parser = parser,
- tree = parser.tree;
+ Phase(this.parser) : tree = parser.tree;
bool processEOF() {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
Token processComment(CommentToken token) {
@@ -635,7 +630,7 @@
}
Token processStartTag(StartTagToken token) {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
Token startTagHtml(StartTagToken token) {
@@ -653,7 +648,7 @@
}
Token processEndTag(EndTagToken token) {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
/// Helper method for popping openElements.
@@ -829,7 +824,7 @@
// helper methods
void insertHtmlElement() {
tree.insertRoot(
- new StartTagToken("html", data: new LinkedHashMap<dynamic, String>()));
+ StartTagToken("html", data: LinkedHashMap<dynamic, String>()));
parser.phase = parser._beforeHeadPhase;
}
@@ -906,8 +901,7 @@
}
bool processEOF() {
- startTagHead(
- new StartTagToken("head", data: new LinkedHashMap<dynamic, String>()));
+ startTagHead(StartTagToken("head", data: LinkedHashMap<dynamic, String>()));
return true;
}
@@ -916,8 +910,7 @@
}
Token processCharacters(CharactersToken token) {
- startTagHead(
- new StartTagToken("head", data: new LinkedHashMap<dynamic, String>()));
+ startTagHead(StartTagToken("head", data: LinkedHashMap<dynamic, String>()));
return token;
}
@@ -932,14 +925,12 @@
}
Token startTagOther(StartTagToken token) {
- startTagHead(
- new StartTagToken("head", data: new LinkedHashMap<dynamic, String>()));
+ startTagHead(StartTagToken("head", data: LinkedHashMap<dynamic, String>()));
return token;
}
Token endTagImplyHead(EndTagToken token) {
- startTagHead(
- new StartTagToken("head", data: new LinkedHashMap<dynamic, String>()));
+ startTagHead(StartTagToken("head", data: LinkedHashMap<dynamic, String>()));
return token;
}
@@ -1037,8 +1028,8 @@
if (charset != null) {
parser.tokenizer.stream.changeEncoding(charset);
} else if (content != null) {
- var data = new EncodingBytes(content);
- var codec = new ContentAttrParser(data).parse();
+ var data = EncodingBytes(content);
+ var codec = ContentAttrParser(data).parse();
parser.tokenizer.stream.changeEncoding(codec);
}
}
@@ -1082,7 +1073,7 @@
}
void anythingElse() {
- endTagHead(new EndTagToken("head"));
+ endTagHead(EndTagToken("head"));
}
}
@@ -1193,7 +1184,7 @@
void anythingElse() {
tree.insertElement(
- new StartTagToken("body", data: new LinkedHashMap<dynamic, String>()));
+ StartTagToken("body", data: LinkedHashMap<dynamic, String>()));
parser.phase = parser._inBodyPhase;
parser.framesetOK = true;
}
@@ -1601,14 +1592,14 @@
void startTagCloseP(StartTagToken token) {
if (tree.elementInScope("p", variant: "button")) {
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
}
tree.insertElement(token);
}
void startTagPreListing(StartTagToken token) {
if (tree.elementInScope("p", variant: "button")) {
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
}
tree.insertElement(token);
parser.framesetOK = false;
@@ -1620,7 +1611,7 @@
parser.parseError(token.span, "unexpected-start-tag", {"name": "form"});
} else {
if (tree.elementInScope("p", variant: "button")) {
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
}
tree.insertElement(token);
tree.formPointer = tree.openElements.last;
@@ -1631,14 +1622,14 @@
parser.framesetOK = false;
final stopNamesMap = const {
- "li": const ["li"],
- "dt": const ["dt", "dd"],
- "dd": const ["dt", "dd"]
+ "li": ["li"],
+ "dt": ["dt", "dd"],
+ "dd": ["dt", "dd"]
};
var stopNames = stopNamesMap[token.name];
for (var node in tree.openElements.reversed) {
if (stopNames.contains(node.localName)) {
- parser.phase.processEndTag(new EndTagToken(node.localName));
+ parser.phase.processEndTag(EndTagToken(node.localName));
break;
}
if (specialElements.contains(getElementNameTuple(node)) &&
@@ -1648,7 +1639,7 @@
}
if (tree.elementInScope("p", variant: "button")) {
- parser.phase.processEndTag(new EndTagToken("p"));
+ parser.phase.processEndTag(EndTagToken("p"));
}
tree.insertElement(token);
@@ -1656,7 +1647,7 @@
void startTagPlaintext(StartTagToken token) {
if (tree.elementInScope("p", variant: "button")) {
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
}
tree.insertElement(token);
parser.tokenizer.state = parser.tokenizer.plaintextState;
@@ -1664,7 +1655,7 @@
void startTagHeading(StartTagToken token) {
if (tree.elementInScope("p", variant: "button")) {
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
}
if (headingElements.contains(tree.openElements.last.localName)) {
parser
@@ -1679,7 +1670,7 @@
if (afeAElement != null) {
parser.parseError(token.span, "unexpected-start-tag-implies-end-tag",
{"startName": "a", "endName": "a"});
- endTagFormatting(new EndTagToken("a"));
+ endTagFormatting(EndTagToken("a"));
tree.openElements.remove(afeAElement);
tree.activeFormattingElements.remove(afeAElement);
}
@@ -1697,7 +1688,7 @@
if (tree.elementInScope("nobr")) {
parser.parseError(token.span, "unexpected-start-tag-implies-end-tag",
{"startName": "nobr", "endName": "nobr"});
- processEndTag(new EndTagToken("nobr"));
+ processEndTag(EndTagToken("nobr"));
// XXX Need tests that trigger the following
tree.reconstructActiveFormattingElements();
}
@@ -1708,7 +1699,7 @@
if (tree.elementInScope("button")) {
parser.parseError(token.span, "unexpected-start-tag-implies-end-tag",
{"startName": "button", "endName": "button"});
- processEndTag(new EndTagToken("button"));
+ processEndTag(EndTagToken("button"));
return token;
} else {
tree.reconstructActiveFormattingElements();
@@ -1727,7 +1718,7 @@
void startTagXmp(StartTagToken token) {
if (tree.elementInScope("p", variant: "button")) {
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
}
tree.reconstructActiveFormattingElements();
parser.framesetOK = false;
@@ -1737,7 +1728,7 @@
void startTagTable(StartTagToken token) {
if (parser.compatMode != "quirks") {
if (tree.elementInScope("p", variant: "button")) {
- processEndTag(new EndTagToken("p"));
+ processEndTag(EndTagToken("p"));
}
}
tree.insertElement(token);
@@ -1770,7 +1761,7 @@
void startTagHr(StartTagToken token) {
if (tree.elementInScope("p", variant: "button")) {
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
}
tree.insertElement(token);
tree.openElements.removeLast();
@@ -1782,8 +1773,8 @@
// No really...
parser.parseError(token.span, "unexpected-start-tag-treated-as",
{"originalName": "image", "newName": "img"});
- processStartTag(new StartTagToken("img",
- data: token.data, selfClosing: token.selfClosing));
+ processStartTag(
+ StartTagToken("img", data: token.data, selfClosing: token.selfClosing));
}
void startTagIsIndex(StartTagToken token) {
@@ -1791,32 +1782,32 @@
if (tree.formPointer != null) {
return;
}
- var formAttrs = new LinkedHashMap<dynamic, String>();
+ var formAttrs = LinkedHashMap<dynamic, String>();
var dataAction = token.data["action"];
if (dataAction != null) {
formAttrs["action"] = dataAction;
}
- processStartTag(new StartTagToken("form", data: formAttrs));
+ processStartTag(StartTagToken("form", data: formAttrs));
processStartTag(
- new StartTagToken("hr", data: new LinkedHashMap<dynamic, String>()));
+ StartTagToken("hr", data: LinkedHashMap<dynamic, String>()));
processStartTag(
- new StartTagToken("label", data: new LinkedHashMap<dynamic, String>()));
+ StartTagToken("label", data: LinkedHashMap<dynamic, String>()));
// XXX Localization ...
var prompt = token.data["prompt"];
if (prompt == null) {
prompt = "This is a searchable index. Enter search keywords: ";
}
- processCharacters(new CharactersToken(prompt));
- var attributes = new LinkedHashMap<dynamic, String>.from(token.data);
+ processCharacters(CharactersToken(prompt));
+ var attributes = LinkedHashMap<dynamic, String>.from(token.data);
attributes.remove('action');
attributes.remove('prompt');
attributes["name"] = "isindex";
- processStartTag(new StartTagToken("input",
+ processStartTag(StartTagToken("input",
data: attributes, selfClosing: token.selfClosing));
- processEndTag(new EndTagToken("label"));
+ processEndTag(EndTagToken("label"));
processStartTag(
- new StartTagToken("hr", data: new LinkedHashMap<dynamic, String>()));
- processEndTag(new EndTagToken("form"));
+ StartTagToken("hr", data: LinkedHashMap<dynamic, String>()));
+ processEndTag(EndTagToken("form"));
}
void startTagTextarea(StartTagToken token) {
@@ -1838,7 +1829,7 @@
void startTagOpt(StartTagToken token) {
if (tree.openElements.last.localName == "option") {
- parser.phase.processEndTag(new EndTagToken("option"));
+ parser.phase.processEndTag(EndTagToken("option"));
}
tree.reconstructActiveFormattingElements();
parser.tree.insertElement(token);
@@ -1919,9 +1910,9 @@
void endTagP(EndTagToken token) {
if (!tree.elementInScope("p", variant: "button")) {
startTagCloseP(
- new StartTagToken("p", data: new LinkedHashMap<dynamic, String>()));
+ StartTagToken("p", data: LinkedHashMap<dynamic, String>()));
parser.parseError(token.span, "unexpected-end-tag", {"name": "p"});
- endTagP(new EndTagToken("p"));
+ endTagP(EndTagToken("p"));
} else {
tree.generateImpliedEndTags("p");
if (tree.openElements.last.localName != "p") {
@@ -1970,7 +1961,7 @@
Token endTagHtml(EndTagToken token) {
//We repeat the test for the body end tag token being ignored here
if (tree.elementInScope("body")) {
- endTagBody(new EndTagToken("body"));
+ endTagBody(EndTagToken("body"));
return token;
}
return null;
@@ -2218,7 +2209,7 @@
{"originalName": "br", "newName": "br element"});
tree.reconstructActiveFormattingElements();
tree.insertElement(
- new StartTagToken("br", data: new LinkedHashMap<dynamic, String>()));
+ StartTagToken("br", data: LinkedHashMap<dynamic, String>()));
tree.openElements.removeLast();
}
@@ -2420,8 +2411,8 @@
}
Token startTagCol(StartTagToken token) {
- startTagColgroup(new StartTagToken("colgroup",
- data: new LinkedHashMap<dynamic, String>()));
+ startTagColgroup(
+ StartTagToken("colgroup", data: LinkedHashMap<dynamic, String>()));
return token;
}
@@ -2433,14 +2424,14 @@
Token startTagImplyTbody(StartTagToken token) {
startTagRowGroup(
- new StartTagToken("tbody", data: new LinkedHashMap<dynamic, String>()));
+ StartTagToken("tbody", data: LinkedHashMap<dynamic, String>()));
return token;
}
Token startTagTable(StartTagToken token) {
parser.parseError(token.span, "unexpected-start-tag-implies-end-tag",
{"startName": "table", "endName": "table"});
- parser.phase.processEndTag(new EndTagToken("table"));
+ parser.phase.processEndTag(EndTagToken("table"));
if (!parser.innerHTMLMode) {
return token;
}
@@ -2535,7 +2526,7 @@
}
if (!allWhitespace(data)) {
- parser._inTablePhase.insertText(new CharactersToken(data)..span = span);
+ parser._inTablePhase.insertText(CharactersToken(data)..span = span);
} else if (data.isNotEmpty) {
tree.insertText(data, span);
}
@@ -2646,7 +2637,7 @@
parser.parseError(token.span, "undefined-error");
//XXX Have to duplicate logic here to find out if the tag is ignored
var ignoreEndTag = ignoreEndTagCaption();
- parser.phase.processEndTag(new EndTagToken("caption"));
+ parser.phase.processEndTag(EndTagToken("caption"));
if (!ignoreEndTag) {
return token;
}
@@ -2684,7 +2675,7 @@
Token endTagTable(EndTagToken token) {
parser.parseError(token.span, "undefined-error");
var ignoreEndTag = ignoreEndTagCaption();
- parser.phase.processEndTag(new EndTagToken("caption"));
+ parser.phase.processEndTag(EndTagToken("caption"));
if (!ignoreEndTag) {
return token;
}
@@ -2739,14 +2730,14 @@
assert(parser.innerHTMLMode);
return false;
} else {
- endTagColgroup(new EndTagToken("colgroup"));
+ endTagColgroup(EndTagToken("colgroup"));
return true;
}
}
Token processCharacters(CharactersToken token) {
var ignoreEndTag = ignoreEndTagColgroup();
- endTagColgroup(new EndTagToken("colgroup"));
+ endTagColgroup(EndTagToken("colgroup"));
return ignoreEndTag ? null : token;
}
@@ -2757,7 +2748,7 @@
Token startTagOther(StartTagToken token) {
var ignoreEndTag = ignoreEndTagColgroup();
- endTagColgroup(new EndTagToken("colgroup"));
+ endTagColgroup(EndTagToken("colgroup"));
return ignoreEndTag ? null : token;
}
@@ -2779,7 +2770,7 @@
Token endTagOther(EndTagToken token) {
var ignoreEndTag = ignoreEndTagColgroup();
- endTagColgroup(new EndTagToken("colgroup"));
+ endTagColgroup(EndTagToken("colgroup"));
return ignoreEndTag ? null : token;
}
}
@@ -2870,8 +2861,7 @@
Token startTagTableCell(StartTagToken token) {
parser.parseError(
token.span, "unexpected-cell-in-table-body", {"name": token.name});
- startTagTr(
- new StartTagToken("tr", data: new LinkedHashMap<dynamic, String>()));
+ startTagTr(StartTagToken("tr", data: LinkedHashMap<dynamic, String>()));
return token;
}
@@ -2899,7 +2889,7 @@
tree.elementInScope("thead", variant: "table") ||
tree.elementInScope("tfoot", variant: "table")) {
clearStackToTableBodyContext();
- endTagTableRowGroup(new EndTagToken(tree.openElements.last.localName));
+ endTagTableRowGroup(EndTagToken(tree.openElements.last.localName));
return token;
} else {
// innerHTML case
@@ -3010,7 +3000,7 @@
Token startTagTableOther(StartTagToken token) {
bool ignoreEndTag = ignoreEndTagTr();
- endTagTr(new EndTagToken("tr"));
+ endTagTr(EndTagToken("tr"));
// XXX how are we sure it's always ignored in the innerHTML case?
return ignoreEndTag ? null : token;
}
@@ -3034,7 +3024,7 @@
Token endTagTable(EndTagToken token) {
var ignoreEndTag = ignoreEndTagTr();
- endTagTr(new EndTagToken("tr"));
+ endTagTr(EndTagToken("tr"));
// Reprocess the current tag if the tr end tag was not ignored
// XXX how are we sure it's always ignored in the innerHTML case?
return ignoreEndTag ? null : token;
@@ -3042,7 +3032,7 @@
Token endTagTableRowGroup(EndTagToken token) {
if (tree.elementInScope(token.name, variant: "table")) {
- endTagTr(new EndTagToken("tr"));
+ endTagTr(EndTagToken("tr"));
return token;
} else {
parser.parseError(token.span, "undefined-error");
@@ -3110,9 +3100,9 @@
// helper
void closeCell() {
if (tree.elementInScope("td", variant: "table")) {
- endTagTableCell(new EndTagToken("td"));
+ endTagTableCell(EndTagToken("td"));
} else if (tree.elementInScope("th", variant: "table")) {
- endTagTableCell(new EndTagToken("th"));
+ endTagTableCell(EndTagToken("th"));
}
}
@@ -3264,13 +3254,13 @@
void startTagSelect(StartTagToken token) {
parser.parseError(token.span, "unexpected-select-in-select");
- endTagSelect(new EndTagToken("select"));
+ endTagSelect(EndTagToken("select"));
}
Token startTagInput(StartTagToken token) {
parser.parseError(token.span, "unexpected-input-in-select");
if (tree.elementInScope("select", variant: "select")) {
- endTagSelect(new EndTagToken("select"));
+ endTagSelect(EndTagToken("select"));
return token;
} else {
assert(parser.innerHTMLMode);
@@ -3382,7 +3372,7 @@
token.span,
"unexpected-table-element-start-tag-in-select-in-table",
{"name": token.name});
- endTagOther(new EndTagToken("select"));
+ endTagOther(EndTagToken("select"));
return token;
}
@@ -3396,7 +3386,7 @@
"unexpected-table-element-end-tag-in-select-in-table",
{"name": token.name});
if (tree.elementInScope(token.name, variant: "table")) {
- endTagOther(new EndTagToken("select"));
+ endTagOther(EndTagToken("select"));
return token;
}
return null;
@@ -3409,7 +3399,7 @@
class InForeignContentPhase extends Phase {
// TODO(jmesserly): this is sorted so we could binary search.
- static const breakoutElements = const [
+ static const breakoutElements = [
'b',
'big',
'blockquote',
@@ -3915,5 +3905,5 @@
Pair<String, String> getElementNameTuple(Element e) {
var ns = e.namespaceUri;
if (ns == null) ns = Namespaces.html;
- return new Pair(ns, e.localName);
+ return Pair(ns, e.localName);
}
diff --git a/lib/parser_console.dart b/lib/parser_console.dart
index 515f891..28dee14 100644
--- a/lib/parser_console.dart
+++ b/lib/parser_console.dart
@@ -11,7 +11,7 @@
/// this means it will be able to handle `dart:io` and [RandomAccessFile]s as
/// input to the various [parse] methods.
void useConsole() {
- inputstream.consoleSupport = new _ConsoleSupport();
+ inputstream.consoleSupport = _ConsoleSupport();
}
class _ConsoleSupport extends inputstream.ConsoleSupport {
@@ -25,7 +25,7 @@
/// Synchronously reads all bytes from the [file].
List<int> readAllBytesFromFile(RandomAccessFile file) {
int length = file.lengthSync();
- var bytes = new List<int>(length);
+ var bytes = List<int>(length);
int bytesRead = 0;
while (bytesRead < length) {
diff --git a/lib/src/char_encodings.dart b/lib/src/char_encodings.dart
index bf1fa47..ba10a4a 100644
--- a/lib/src/char_encodings.dart
+++ b/lib/src/char_encodings.dart
@@ -36,7 +36,7 @@
// TODO(jmesserly): ideally this would be DecoderException, like the
// one thrown in runtime/bin/string_stream.dart, but we don't want to
// depend on dart:io.
- throw new FormatException("Illegal ASCII character $byte");
+ throw FormatException("Illegal ASCII character $byte");
}
}
return bytes;
@@ -69,7 +69,7 @@
return decodeUtf32leAsIterable(bytes, offset, length, true, replace);
default:
- throw new ArgumentError('Encoding $encoding not supported');
+ throw ArgumentError('Encoding $encoding not supported');
}
}
@@ -103,7 +103,7 @@
[int offset = 0,
int length,
int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) {
- return new IterableWindows1252Decoder(
+ return IterableWindows1252Decoder(
bytes, offset, length, replacementCodepoint);
}
@@ -122,7 +122,7 @@
this.replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]);
Windows1252Decoder get iterator =>
- new Windows1252Decoder(bytes, offset, length, replacementCodepoint);
+ Windows1252Decoder(bytes, offset, length, replacementCodepoint);
}
/// Provides an iterator of Unicode codepoints from windows-1252 encoded bytes.
@@ -218,7 +218,7 @@
case 0x90:
case 0x9D:
if (replacementCodepoint == null) {
- throw new ArgumentError(
+ throw ArgumentError(
"Invalid windows-1252 code point $char at $_offset");
}
return replacementCodepoint;
diff --git a/lib/src/constants.dart b/lib/src/constants.dart
index 9f4878f..fc0c6a1 100644
--- a/lib/src/constants.dart
+++ b/lib/src/constants.dart
@@ -6,7 +6,7 @@
// lookup than linear search "contains". In the Python code they were
// frozensets.
-final String EOF = null;
+final String eof = null;
class ReparseException implements Exception {
final String message;
@@ -19,7 +19,7 @@
/// These are error messages emitted by [HtmlParser]. The values use Python
/// style string formatting, as implemented by [formatStr]. That function only
/// supports the subset of format functionality used here.
-const Map<String, String> errorMessages = const {
+const Map<String, String> errorMessages = {
"null-character": "Null character in input stream, replaced with U+FFFD.",
"invalid-codepoint": "Invalid codepoint in stream.",
"incorrectly-placed-solidus": "Solidus (/) incorrectly placed in tag.",
@@ -264,139 +264,139 @@
}
}
-const List scopingElements = const [
- const Pair(Namespaces.html, "applet"),
- const Pair(Namespaces.html, "caption"),
- const Pair(Namespaces.html, "html"),
- const Pair(Namespaces.html, "marquee"),
- const Pair(Namespaces.html, "object"),
- const Pair(Namespaces.html, "table"),
- const Pair(Namespaces.html, "td"),
- const Pair(Namespaces.html, "th"),
- const Pair(Namespaces.mathml, "mi"),
- const Pair(Namespaces.mathml, "mo"),
- const Pair(Namespaces.mathml, "mn"),
- const Pair(Namespaces.mathml, "ms"),
- const Pair(Namespaces.mathml, "mtext"),
- const Pair(Namespaces.mathml, "annotation-xml"),
- const Pair(Namespaces.svg, "foreignObject"),
- const Pair(Namespaces.svg, "desc"),
- const Pair(Namespaces.svg, "title")
+const List scopingElements = [
+ Pair(Namespaces.html, "applet"),
+ Pair(Namespaces.html, "caption"),
+ Pair(Namespaces.html, "html"),
+ Pair(Namespaces.html, "marquee"),
+ Pair(Namespaces.html, "object"),
+ Pair(Namespaces.html, "table"),
+ Pair(Namespaces.html, "td"),
+ Pair(Namespaces.html, "th"),
+ Pair(Namespaces.mathml, "mi"),
+ Pair(Namespaces.mathml, "mo"),
+ Pair(Namespaces.mathml, "mn"),
+ Pair(Namespaces.mathml, "ms"),
+ Pair(Namespaces.mathml, "mtext"),
+ Pair(Namespaces.mathml, "annotation-xml"),
+ Pair(Namespaces.svg, "foreignObject"),
+ Pair(Namespaces.svg, "desc"),
+ Pair(Namespaces.svg, "title")
];
-const formattingElements = const [
- const Pair(Namespaces.html, "a"),
- const Pair(Namespaces.html, "b"),
- const Pair(Namespaces.html, "big"),
- const Pair(Namespaces.html, "code"),
- const Pair(Namespaces.html, "em"),
- const Pair(Namespaces.html, "font"),
- const Pair(Namespaces.html, "i"),
- const Pair(Namespaces.html, "nobr"),
- const Pair(Namespaces.html, "s"),
- const Pair(Namespaces.html, "small"),
- const Pair(Namespaces.html, "strike"),
- const Pair(Namespaces.html, "strong"),
- const Pair(Namespaces.html, "tt"),
- const Pair(Namespaces.html, "")
+const formattingElements = [
+ Pair(Namespaces.html, "a"),
+ Pair(Namespaces.html, "b"),
+ Pair(Namespaces.html, "big"),
+ Pair(Namespaces.html, "code"),
+ Pair(Namespaces.html, "em"),
+ Pair(Namespaces.html, "font"),
+ Pair(Namespaces.html, "i"),
+ Pair(Namespaces.html, "nobr"),
+ Pair(Namespaces.html, "s"),
+ Pair(Namespaces.html, "small"),
+ Pair(Namespaces.html, "strike"),
+ Pair(Namespaces.html, "strong"),
+ Pair(Namespaces.html, "tt"),
+ Pair(Namespaces.html, "")
];
-const specialElements = const [
- const Pair(Namespaces.html, "address"),
- const Pair(Namespaces.html, "applet"),
- const Pair(Namespaces.html, "area"),
- const Pair(Namespaces.html, "article"),
- const Pair(Namespaces.html, "aside"),
- const Pair(Namespaces.html, "base"),
- const Pair(Namespaces.html, "basefont"),
- const Pair(Namespaces.html, "bgsound"),
- const Pair(Namespaces.html, "blockquote"),
- const Pair(Namespaces.html, "body"),
- const Pair(Namespaces.html, "br"),
- const Pair(Namespaces.html, "button"),
- const Pair(Namespaces.html, "caption"),
- const Pair(Namespaces.html, "center"),
- const Pair(Namespaces.html, "col"),
- const Pair(Namespaces.html, "colgroup"),
- const Pair(Namespaces.html, "command"),
- const Pair(Namespaces.html, "dd"),
- const Pair(Namespaces.html, "details"),
- const Pair(Namespaces.html, "dir"),
- const Pair(Namespaces.html, "div"),
- const Pair(Namespaces.html, "dl"),
- const Pair(Namespaces.html, "dt"),
- const Pair(Namespaces.html, "embed"),
- const Pair(Namespaces.html, "fieldset"),
- const Pair(Namespaces.html, "figure"),
- const Pair(Namespaces.html, "footer"),
- const Pair(Namespaces.html, "form"),
- const Pair(Namespaces.html, "frame"),
- const Pair(Namespaces.html, "frameset"),
- const Pair(Namespaces.html, "h1"),
- const Pair(Namespaces.html, "h2"),
- const Pair(Namespaces.html, "h3"),
- const Pair(Namespaces.html, "h4"),
- const Pair(Namespaces.html, "h5"),
- const Pair(Namespaces.html, "h6"),
- const Pair(Namespaces.html, "head"),
- const Pair(Namespaces.html, "header"),
- const Pair(Namespaces.html, "hr"),
- const Pair(Namespaces.html, "html"),
- const Pair(Namespaces.html, "iframe"),
+const specialElements = [
+ Pair(Namespaces.html, "address"),
+ Pair(Namespaces.html, "applet"),
+ Pair(Namespaces.html, "area"),
+ Pair(Namespaces.html, "article"),
+ Pair(Namespaces.html, "aside"),
+ Pair(Namespaces.html, "base"),
+ Pair(Namespaces.html, "basefont"),
+ Pair(Namespaces.html, "bgsound"),
+ Pair(Namespaces.html, "blockquote"),
+ Pair(Namespaces.html, "body"),
+ Pair(Namespaces.html, "br"),
+ Pair(Namespaces.html, "button"),
+ Pair(Namespaces.html, "caption"),
+ Pair(Namespaces.html, "center"),
+ Pair(Namespaces.html, "col"),
+ Pair(Namespaces.html, "colgroup"),
+ Pair(Namespaces.html, "command"),
+ Pair(Namespaces.html, "dd"),
+ Pair(Namespaces.html, "details"),
+ Pair(Namespaces.html, "dir"),
+ Pair(Namespaces.html, "div"),
+ Pair(Namespaces.html, "dl"),
+ Pair(Namespaces.html, "dt"),
+ Pair(Namespaces.html, "embed"),
+ Pair(Namespaces.html, "fieldset"),
+ Pair(Namespaces.html, "figure"),
+ Pair(Namespaces.html, "footer"),
+ Pair(Namespaces.html, "form"),
+ Pair(Namespaces.html, "frame"),
+ Pair(Namespaces.html, "frameset"),
+ Pair(Namespaces.html, "h1"),
+ Pair(Namespaces.html, "h2"),
+ Pair(Namespaces.html, "h3"),
+ Pair(Namespaces.html, "h4"),
+ Pair(Namespaces.html, "h5"),
+ Pair(Namespaces.html, "h6"),
+ Pair(Namespaces.html, "head"),
+ Pair(Namespaces.html, "header"),
+ Pair(Namespaces.html, "hr"),
+ Pair(Namespaces.html, "html"),
+ Pair(Namespaces.html, "iframe"),
// Note that image is commented out in the spec as "this isn't an
// element that can end up on the stack, so it doesn't matter,"
- const Pair(Namespaces.html, "image"),
- const Pair(Namespaces.html, "img"),
- const Pair(Namespaces.html, "input"),
- const Pair(Namespaces.html, "isindex"),
- const Pair(Namespaces.html, "li"),
- const Pair(Namespaces.html, "link"),
- const Pair(Namespaces.html, "listing"),
- const Pair(Namespaces.html, "marquee"),
- const Pair(Namespaces.html, "men"),
- const Pair(Namespaces.html, "meta"),
- const Pair(Namespaces.html, "nav"),
- const Pair(Namespaces.html, "noembed"),
- const Pair(Namespaces.html, "noframes"),
- const Pair(Namespaces.html, "noscript"),
- const Pair(Namespaces.html, "object"),
- const Pair(Namespaces.html, "ol"),
- const Pair(Namespaces.html, "p"),
- const Pair(Namespaces.html, "param"),
- const Pair(Namespaces.html, "plaintext"),
- const Pair(Namespaces.html, "pre"),
- const Pair(Namespaces.html, "script"),
- const Pair(Namespaces.html, "section"),
- const Pair(Namespaces.html, "select"),
- const Pair(Namespaces.html, "style"),
- const Pair(Namespaces.html, "table"),
- const Pair(Namespaces.html, "tbody"),
- const Pair(Namespaces.html, "td"),
- const Pair(Namespaces.html, "textarea"),
- const Pair(Namespaces.html, "tfoot"),
- const Pair(Namespaces.html, "th"),
- const Pair(Namespaces.html, "thead"),
- const Pair(Namespaces.html, "title"),
- const Pair(Namespaces.html, "tr"),
- const Pair(Namespaces.html, "ul"),
- const Pair(Namespaces.html, "wbr"),
- const Pair(Namespaces.html, "xmp"),
- const Pair(Namespaces.svg, "foreignObject")
+ Pair(Namespaces.html, "image"),
+ Pair(Namespaces.html, "img"),
+ Pair(Namespaces.html, "input"),
+ Pair(Namespaces.html, "isindex"),
+ Pair(Namespaces.html, "li"),
+ Pair(Namespaces.html, "link"),
+ Pair(Namespaces.html, "listing"),
+ Pair(Namespaces.html, "marquee"),
+ Pair(Namespaces.html, "men"),
+ Pair(Namespaces.html, "meta"),
+ Pair(Namespaces.html, "nav"),
+ Pair(Namespaces.html, "noembed"),
+ Pair(Namespaces.html, "noframes"),
+ Pair(Namespaces.html, "noscript"),
+ Pair(Namespaces.html, "object"),
+ Pair(Namespaces.html, "ol"),
+ Pair(Namespaces.html, "p"),
+ Pair(Namespaces.html, "param"),
+ Pair(Namespaces.html, "plaintext"),
+ Pair(Namespaces.html, "pre"),
+ Pair(Namespaces.html, "script"),
+ Pair(Namespaces.html, "section"),
+ Pair(Namespaces.html, "select"),
+ Pair(Namespaces.html, "style"),
+ Pair(Namespaces.html, "table"),
+ Pair(Namespaces.html, "tbody"),
+ Pair(Namespaces.html, "td"),
+ Pair(Namespaces.html, "textarea"),
+ Pair(Namespaces.html, "tfoot"),
+ Pair(Namespaces.html, "th"),
+ Pair(Namespaces.html, "thead"),
+ Pair(Namespaces.html, "title"),
+ Pair(Namespaces.html, "tr"),
+ Pair(Namespaces.html, "ul"),
+ Pair(Namespaces.html, "wbr"),
+ Pair(Namespaces.html, "xmp"),
+ Pair(Namespaces.svg, "foreignObject")
];
-const htmlIntegrationPointElements = const [
- const Pair(Namespaces.mathml, "annotaion-xml"),
- const Pair(Namespaces.svg, "foreignObject"),
- const Pair(Namespaces.svg, "desc"),
- const Pair(Namespaces.svg, "title")
+const htmlIntegrationPointElements = [
+ Pair(Namespaces.mathml, "annotaion-xml"),
+ Pair(Namespaces.svg, "foreignObject"),
+ Pair(Namespaces.svg, "desc"),
+ Pair(Namespaces.svg, "title")
];
-const mathmlTextIntegrationPointElements = const [
- const Pair(Namespaces.mathml, "mi"),
- const Pair(Namespaces.mathml, "mo"),
- const Pair(Namespaces.mathml, "mn"),
- const Pair(Namespaces.mathml, "ms"),
- const Pair(Namespaces.mathml, "mtext")
+const mathmlTextIntegrationPointElements = [
+ Pair(Namespaces.mathml, "mi"),
+ Pair(Namespaces.mathml, "mo"),
+ Pair(Namespaces.mathml, "mn"),
+ Pair(Namespaces.mathml, "ms"),
+ Pair(Namespaces.mathml, "mtext")
];
const spaceCharacters = " \n\r\t\u000C";
@@ -421,7 +421,7 @@
return false;
}
-const List<String> tableInsertModeElements = const [
+const List<String> tableInsertModeElements = [
"table",
"tbody",
"tfoot",
@@ -487,7 +487,7 @@
// ASCII chars to.toLowerCase() case, unlike Dart's toLowerCase function.
String asciiUpper2Lower(String text) {
if (text == null) return null;
- var result = new List<int>(text.length);
+ var result = List<int>(text.length);
for (int i = 0; i < text.length; i++) {
var c = text.codeUnitAt(i);
if (c >= UPPER_A && c <= UPPER_Z) {
@@ -495,15 +495,15 @@
}
result[i] = c;
}
- return new String.fromCharCodes(result);
+ return String.fromCharCodes(result);
}
// Heading elements need to be ordered
-const headingElements = const ["h1", "h2", "h3", "h4", "h5", "h6"];
+const headingElements = ["h1", "h2", "h3", "h4", "h5", "h6"];
-const cdataElements = const ['title', 'textarea'];
+const cdataElements = ['title', 'textarea'];
-const rcdataElements = const [
+const rcdataElements = [
'style',
'script',
'xmp',
@@ -513,33 +513,33 @@
'noscript'
];
-const Map<String, List<String>> booleanAttributes = const {
- "": const [
+const Map<String, List<String>> booleanAttributes = {
+ "": [
"irrelevant",
],
- "style": const [
+ "style": [
"scoped",
],
- "img": const [
+ "img": [
"ismap",
],
- "audio": const ["autoplay", "controls"],
- "video": const ["autoplay", "controls"],
- "script": const ["defer", "async"],
- "details": const [
+ "audio": ["autoplay", "controls"],
+ "video": ["autoplay", "controls"],
+ "script": ["defer", "async"],
+ "details": [
"open",
],
- "datagrid": const ["multiple", "disabled"],
- "command": const ["hidden", "disabled", "checked", "default"],
- "hr": const ["noshade"],
- "men": const [
+ "datagrid": ["multiple", "disabled"],
+ "command": ["hidden", "disabled", "checked", "default"],
+ "hr": ["noshade"],
+ "men": [
"autosubmit",
],
- "fieldset": const ["disabled", "readonly"],
- "option": const ["disabled", "readonly", "selected"],
- "optgroup": const ["disabled", "readonly"],
- "button": const ["disabled", "autofocus"],
- "input": const [
+ "fieldset": ["disabled", "readonly"],
+ "option": ["disabled", "readonly", "selected"],
+ "optgroup": ["disabled", "readonly"],
+ "button": ["disabled", "autofocus"],
+ "input": [
"disabled",
"readonly",
"required",
@@ -547,13 +547,13 @@
"checked",
"ismap"
],
- "select": const ["disabled", "readonly", "autofocus", "multiple"],
- "output": const ["disabled", "readonly"],
+ "select": ["disabled", "readonly", "autofocus", "multiple"],
+ "output": ["disabled", "readonly"],
};
// entitiesWindows1252 has to be _ordered_ and needs to have an index. It
// therefore can't be a frozenset.
-const List<int> entitiesWindows1252 = const [
+const List<int> entitiesWindows1252 = [
8364, // 0x80 0x20AC EURO SIGN
65533, // 0x81 UNDEFINED
8218, // 0x82 0x201A SINGLE LOW-9 QUOTATION MARK
@@ -588,9 +588,9 @@
376 // 0x9F 0x0178 LATIN CAPITAL LETTER Y WITH DIAERESIS
];
-const xmlEntities = const ['lt;', 'gt;', 'amp;', 'apos;', 'quot;'];
+const xmlEntities = ['lt;', 'gt;', 'amp;', 'apos;', 'quot;'];
-const Map<String, String> entities = const {
+const Map<String, String> entities = {
"AElig": "\xc6",
"AElig;": "\xc6",
"AMP": "&",
@@ -2824,7 +2824,7 @@
"zwnj;": "\u200c",
};
-const Map<int, String> replacementCharacters = const {
+const Map<int, String> replacementCharacters = {
0x00: "\uFFFD",
0x0d: "\u000D",
0x80: "\u20AC",
@@ -2861,7 +2861,7 @@
0x9F: "\u0178"
};
-const Map<String, String> encodings = const {
+const Map<String, String> encodings = {
'437': 'cp437',
'850': 'cp850',
'852': 'cp852',
diff --git a/lib/src/css_class_set.dart b/lib/src/css_class_set.dart
index eca2400..939bf41 100644
--- a/lib/src/css_class_set.dart
+++ b/lib/src/css_class_set.dart
@@ -15,7 +15,7 @@
ElementCssClassSet(this._element);
Set<String> readClasses() {
- var s = new LinkedHashSet<String>();
+ var s = LinkedHashSet<String>();
var classname = _element.className;
for (String name in classname.split(' ')) {
@@ -32,79 +32,63 @@
}
}
-/** A Set that stores the CSS class names for an element. */
+/// A Set that stores the CSS class names for an element.
abstract class CssClassSet implements Set<String> {
- /**
- * Adds the class [value] to the element if it is not on it, removes it if it
- * is.
- *
- * If [shouldAdd] is true, then we always add that [value] to the element. If
- * [shouldAdd] is false then we always remove [value] from the element.
- */
+ /// Adds the class [value] to the element if it is not on it, removes it if it
+ /// is.
+ ///
+ /// If [shouldAdd] is true, then we always add that [value] to the element. If
+ /// [shouldAdd] is false then we always remove [value] from the element.
bool toggle(String value, [bool shouldAdd]);
- /**
- * Returns [:true:] if classes cannot be added or removed from this
- * [:CssClassSet:].
- */
+ /// Returns [:true:] if classes cannot be added or removed from this
+ /// [:CssClassSet:].
bool get frozen;
- /**
- * Determine if this element contains the class [value].
- *
- * This is the Dart equivalent of jQuery's
- * [hasClass](http://api.jquery.com/hasClass/).
- */
+ /// Determine if this element contains the class [value].
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [hasClass](http://api.jquery.com/hasClass/).
bool contains(Object value);
- /**
- * Add the class [value] to element.
- *
- * This is the Dart equivalent of jQuery's
- * [addClass](http://api.jquery.com/addClass/).
- *
- * If this corresponds to one element. Returns true if [value] was added to
- * the set, otherwise false.
- *
- * If this corresponds to many elements, null is always returned.
- */
+ /// Add the class [value] to element.
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [addClass](http://api.jquery.com/addClass/).
+ ///
+ /// If this corresponds to one element. Returns true if [value] was added to
+ /// the set, otherwise false.
+ ///
+ /// If this corresponds to many elements, null is always returned.
bool add(String value);
- /**
- * Remove the class [value] from element, and return true on successful
- * removal.
- *
- * This is the Dart equivalent of jQuery's
- * [removeClass](http://api.jquery.com/removeClass/).
- */
+ /// Remove the class [value] from element, and return true on successful
+ /// removal.
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [removeClass](http://api.jquery.com/removeClass/).
bool remove(Object value);
- /**
- * Add all classes specified in [iterable] to element.
- *
- * This is the Dart equivalent of jQuery's
- * [addClass](http://api.jquery.com/addClass/).
- */
+ /// Add all classes specified in [iterable] to element.
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [addClass](http://api.jquery.com/addClass/).
void addAll(Iterable<String> iterable);
- /**
- * Remove all classes specified in [iterable] from element.
- *
- * This is the Dart equivalent of jQuery's
- * [removeClass](http://api.jquery.com/removeClass/).
- */
+ /// Remove all classes specified in [iterable] from element.
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [removeClass](http://api.jquery.com/removeClass/).
void removeAll(Iterable<Object> iterable);
- /**
- * Toggles all classes specified in [iterable] on element.
- *
- * Iterate through [iterable]'s items, and add it if it is not on it, or
- * remove it if it is. This is the Dart equivalent of jQuery's
- * [toggleClass](http://api.jquery.com/toggleClass/).
- * If [shouldAdd] is true, then we always add all the classes in [iterable]
- * element. If [shouldAdd] is false then we always remove all the classes in
- * [iterable] from the element.
- */
+ /// Toggles all classes specified in [iterable] on element.
+ ///
+ /// Iterate through [iterable]'s items, and add it if it is not on it, or
+ /// remove it if it is. This is the Dart equivalent of jQuery's
+ /// [toggleClass](http://api.jquery.com/toggleClass/).
+ /// If [shouldAdd] is true, then we always add all the classes in [iterable]
+ /// element. If [shouldAdd] is false then we always remove all the classes in
+ /// [iterable] from the element.
void toggleAll(Iterable<String> iterable, [bool shouldAdd]);
}
@@ -113,13 +97,11 @@
return readClasses().join(' ');
}
- /**
- * Adds the class [value] to the element if it is not on it, removes it if it
- * is.
- *
- * If [shouldAdd] is true, then we always add that [value] to the element. If
- * [shouldAdd] is false then we always remove [value] from the element.
- */
+ /// Adds the class [value] to the element if it is not on it, removes it if it
+ /// is.
+ ///
+ /// If [shouldAdd] is true, then we always add that [value] to the element. If
+ /// [shouldAdd] is false then we always remove [value] from the element.
bool toggle(String value, [bool shouldAdd]) {
Set<String> s = readClasses();
bool result = false;
@@ -134,10 +116,8 @@
return result;
}
- /**
- * Returns [:true:] if classes cannot be added or removed from this
- * [:CssClassSet:].
- */
+ /// Returns [:true:] if classes cannot be added or removed from this
+ /// [:CssClassSet:].
bool get frozen => false;
Iterator<String> get iterator => readClasses().iterator;
@@ -145,38 +125,32 @@
int get length => readClasses().length;
// interface Set - BEGIN
- /**
- * Determine if this element contains the class [value].
- *
- * This is the Dart equivalent of jQuery's
- * [hasClass](http://api.jquery.com/hasClass/).
- */
+ /// Determine if this element contains the class [value].
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [hasClass](http://api.jquery.com/hasClass/).
bool contains(Object value) => readClasses().contains(value);
- /** Lookup from the Set interface. Not interesting for a String set. */
+ /// Lookup from the Set interface. Not interesting for a String set.
String lookup(Object value) => contains(value) ? value as String : null;
Set<String> toSet() => readClasses().toSet();
- /**
- * Add the class [value] to element.
- *
- * This is the Dart equivalent of jQuery's
- * [addClass](http://api.jquery.com/addClass/).
- */
+ /// Add the class [value] to element.
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [addClass](http://api.jquery.com/addClass/).
bool add(String value) {
// TODO - figure out if we need to do any validation here
// or if the browser natively does enough.
return _modify((s) => s.add(value));
}
- /**
- * Remove the class [value] from element, and return true on successful
- * removal.
- *
- * This is the Dart equivalent of jQuery's
- * [removeClass](http://api.jquery.com/removeClass/).
- */
+ /// Remove the class [value] from element, and return true on successful
+ /// removal.
+ ///
+ /// This is the Dart equivalent of jQuery's
+ /// [removeClass](http://api.jquery.com/removeClass/).
bool remove(Object value) {
if (value is! String) return false;
Set<String> s = readClasses();
@@ -185,29 +159,25 @@
return result;
}
- /**
- * Toggles all classes specified in [iterable] on element.
- *
- * Iterate through [iterable]'s items, and add it if it is not on it, or
- * remove it if it is. This is the Dart equivalent of jQuery's
- * [toggleClass](http://api.jquery.com/toggleClass/).
- * If [shouldAdd] is true, then we always add all the classes in [iterable]
- * element. If [shouldAdd] is false then we always remove all the classes in
- * [iterable] from the element.
- */
+ /// Toggles all classes specified in [iterable] on element.
+ ///
+ /// Iterate through [iterable]'s items, and add it if it is not on it, or
+ /// remove it if it is. This is the Dart equivalent of jQuery's
+ /// [toggleClass](http://api.jquery.com/toggleClass/).
+ /// If [shouldAdd] is true, then we always add all the classes in [iterable]
+ /// element. If [shouldAdd] is false then we always remove all the classes in
+ /// [iterable] from the element.
void toggleAll(Iterable<String> iterable, [bool shouldAdd]) {
iterable.forEach((e) => toggle(e, shouldAdd));
}
- /**
- * Helper method used to modify the set of css classes on this element.
- *
- * f - callback with:
- * s - a Set of all the css class name currently on this element.
- *
- * After f returns, the modified set is written to the
- * className property of this element.
- */
+ /// Helper method used to modify the set of css classes on this element.
+ ///
+ /// f - callback with:
+ /// s - a Set of all the css class name currently on this element.
+ ///
+ /// After f returns, the modified set is written to the
+ /// className property of this element.
bool _modify(bool f(Set<String> s)) {
Set<String> s = readClasses();
var ret = f(s);
@@ -215,17 +185,13 @@
return ret;
}
- /**
- * Read the class names from the Element class property,
- * and put them into a set (duplicates are discarded).
- * This is intended to be overridden by specific implementations.
- */
+ /// Read the class names from the Element class property,
+ /// and put them into a set (duplicates are discarded).
+ /// This is intended to be overridden by specific implementations.
Set<String> readClasses();
- /**
- * Join all the elements of a set into one string and write
- * back to the element.
- * This is intended to be overridden by specific implementations.
- */
+ /// Join all the elements of a set into one string and write
+ /// back to the element.
+ /// This is intended to be overridden by specific implementations.
void writeClasses(Set<String> s);
}
diff --git a/lib/src/encoding_parser.dart b/lib/src/encoding_parser.dart
index ef5e708..280e7dd 100644
--- a/lib/src/encoding_parser.dart
+++ b/lib/src/encoding_parser.dart
@@ -19,9 +19,9 @@
String next() {
var p = _position = _position + 1;
if (p >= length) {
- throw new StateError("No more elements");
+ throw StateError("No more elements");
} else if (p < 0) {
- throw new RangeError(p);
+ throw RangeError(p);
}
return _bytes[p];
}
@@ -29,9 +29,9 @@
String previous() {
var p = _position;
if (p >= length) {
- throw new StateError("No more elements");
+ throw StateError("No more elements");
} else if (p < 0) {
- throw new RangeError(p);
+ throw RangeError(p);
}
_position = p = p - 1;
return _bytes[p];
@@ -39,14 +39,14 @@
set position(int value) {
if (_position >= length) {
- throw new StateError("No more elements");
+ throw StateError("No more elements");
}
_position = value;
}
int get position {
if (_position >= length) {
- throw new StateError("No more elements");
+ throw StateError("No more elements");
}
if (_position >= 0) {
return _position;
@@ -110,7 +110,7 @@
_position = newPosition + bytes.length - 1;
return true;
} else {
- throw new StateError("No more elements");
+ throw StateError("No more elements");
}
}
@@ -137,16 +137,16 @@
/// [bytes] - the data to work on for encoding detection.
EncodingParser(List<int> bytes)
// Note: this is intentionally interpreting bytes as codepoints.
- : data = new EncodingBytes(new String.fromCharCodes(bytes).toLowerCase());
+ : data = EncodingBytes(String.fromCharCodes(bytes).toLowerCase());
String getEncoding() {
final methodDispatch = [
- new _DispatchEntry("<!--", handleComment),
- new _DispatchEntry("<meta", handleMeta),
- new _DispatchEntry("</", handlePossibleEndTag),
- new _DispatchEntry("<!", handleOther),
- new _DispatchEntry("<?", handleOther),
- new _DispatchEntry("<", handlePossibleStartTag),
+ _DispatchEntry("<!--", handleComment),
+ _DispatchEntry("<meta", handleMeta),
+ _DispatchEntry("</", handlePossibleEndTag),
+ _DispatchEntry("<!", handleOther),
+ _DispatchEntry("<?", handleOther),
+ _DispatchEntry("<", handlePossibleStartTag),
];
try {
@@ -191,7 +191,7 @@
return false;
}
} else if (attr[0] == "content") {
- var contentParser = new ContentAttrParser(new EncodingBytes(attr[1]));
+ var contentParser = ContentAttrParser(EncodingBytes(attr[1]));
var tentativeEncoding = contentParser.parse();
var codec = codecName(tentativeEncoding);
if (codec != null) {
diff --git a/lib/src/inputstream.dart b/lib/src/inputstream.dart
index d683277..dbcf98b 100644
--- a/lib/src/inputstream.dart
+++ b/lib/src/inputstream.dart
@@ -14,7 +14,7 @@
}
// TODO(jmesserly): use lazy init here when supported.
-ConsoleSupport consoleSupport = new ConsoleSupport();
+ConsoleSupport consoleSupport = ConsoleSupport();
/// Provides a unicode stream of characters to the HtmlTokenizer.
///
@@ -88,7 +88,7 @@
if (_rawBytes == null) {
// TODO(jmesserly): we should accept some kind of stream API too.
// Unfortunately dart:io InputStream is async only, which won't work.
- throw new ArgumentError("'source' must be a String or "
+ throw ArgumentError("'source' must be a String or "
"List<int> (of bytes). You can also pass a RandomAccessFile if you"
"`import 'package:html/parser_console.dart'` and call "
"`useConsole()`.");
@@ -104,7 +104,7 @@
}
void reset() {
- errors = new Queue<String>();
+ errors = Queue<String>();
_offset = 0;
_lineStarts = <int>[0];
@@ -139,7 +139,7 @@
// TODO(sigmund): Don't parse the file at all if spans aren't being
// generated.
- fileInfo = new SourceFile.decoded(_chars, url: sourceUrl);
+ fileInfo = SourceFile.decoded(_chars, url: sourceUrl);
}
void detectEncoding([bool parseMeta = true]) {
@@ -170,7 +170,7 @@
if (_rawBytes == null) {
// We should never get here -- if encoding is certain we won't try to
// change it.
- throw new StateError('cannot change encoding when parsing a String.');
+ throw StateError('cannot change encoding when parsing a String.');
}
newEncoding = codecName(newEncoding);
@@ -186,7 +186,7 @@
charEncodingCertain = true;
_rawChars = null;
reset();
- throw new ReparseException(
+ throw ReparseException(
'Encoding changed from $charEncodingName to $newEncoding');
}
}
@@ -212,7 +212,7 @@
/// Report the encoding declared by the meta element.
String detectEncodingMeta() {
- var parser = new EncodingParser(slice(_rawBytes, 0, numBytesMeta));
+ var parser = EncodingParser(slice(_rawBytes, 0, numBytesMeta));
var encoding = parser.getEncoding();
if (const ['utf-16', 'utf-16-be', 'utf-16-le'].contains(encoding)) {
@@ -229,13 +229,13 @@
/// Read one character from the stream or queue if available. Return
/// EOF when EOF is reached.
String char() {
- if (_offset >= _chars.length) return EOF;
- return new String.fromCharCodes([_chars[_offset++]]);
+ if (_offset >= _chars.length) return eof;
+ return String.fromCharCodes([_chars[_offset++]]);
}
String peekChar() {
- if (_offset >= _chars.length) return EOF;
- return new String.fromCharCodes([_chars[_offset]]);
+ if (_offset >= _chars.length) return eof;
+ return String.fromCharCodes([_chars[_offset]]);
}
/// Returns a string of characters from the stream up to but not
@@ -247,7 +247,7 @@
_offset++;
}
- return new String.fromCharCodes(_chars.sublist(start, _offset));
+ return String.fromCharCodes(_chars.sublist(start, _offset));
}
void unget(String ch) {
@@ -312,7 +312,7 @@
/// Return the python codec name corresponding to an encoding or null if the
/// string doesn't correspond to a valid encoding.
String codecName(String encoding) {
- final asciiPunctuation = new RegExp(
+ final asciiPunctuation = RegExp(
"[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]");
if (encoding == null) return null;
diff --git a/lib/src/query_selector.dart b/lib/src/query_selector.dart
index 38045d4..0503707 100644
--- a/lib/src/query_selector.dart
+++ b/lib/src/query_selector.dart
@@ -2,21 +2,20 @@
library html.src.query;
import 'package:csslib/parser.dart' as css;
-import 'package:csslib/parser.dart' show TokenKind;
-import 'package:csslib/src/messages.dart' show Message;
+import 'package:csslib/parser.dart' show TokenKind, Message;
import 'package:csslib/visitor.dart'; // the CSSOM
import 'package:html/dom.dart';
import 'package:html/src/constants.dart' show isWhitespaceCC;
bool matches(Node node, String selector) =>
- new SelectorEvaluator().matches(node, _parseSelectorList(selector));
+ SelectorEvaluator().matches(node, _parseSelectorList(selector));
Element querySelector(Node node, String selector) =>
- new SelectorEvaluator().querySelector(node, _parseSelectorList(selector));
+ SelectorEvaluator().querySelector(node, _parseSelectorList(selector));
List<Element> querySelectorAll(Node node, String selector) {
var results = <Element>[];
- new SelectorEvaluator()
+ SelectorEvaluator()
.querySelectorAll(node, _parseSelectorList(selector), results);
return results;
}
@@ -26,7 +25,7 @@
var errors = <Message>[];
var group = css.parseSelectorGroup(selector, errors: errors);
if (group == null || errors.isNotEmpty) {
- throw new FormatException("'$selector' is not a valid selector: $errors");
+ throw FormatException("'$selector' is not a valid selector: $errors");
}
return group;
}
@@ -125,11 +124,11 @@
}
_unimplemented(SimpleSelector selector) =>
- new UnimplementedError("'$selector' selector of type "
+ UnimplementedError("'$selector' selector of type "
"${selector.runtimeType} is not implemented");
_unsupported(selector) =>
- new FormatException("'$selector' is not a valid selector");
+ FormatException("'$selector' is not a valid selector");
bool visitPseudoClassSelector(PseudoClassSelector selector) {
switch (selector.name) {
diff --git a/lib/src/token.dart b/lib/src/token.dart
index 877a6a3..ea0a855 100644
--- a/lib/src/token.dart
+++ b/lib/src/token.dart
@@ -34,8 +34,8 @@
StartTagToken(String name,
{this.data,
- bool selfClosing: false,
- this.selfClosingAcknowledged: false,
+ bool selfClosing = false,
+ this.selfClosingAcknowledged = false,
this.namespace})
: super(name, selfClosing);
@@ -43,7 +43,7 @@
}
class EndTagToken extends TagToken {
- EndTagToken(String name, {bool selfClosing: false})
+ EndTagToken(String name, {bool selfClosing = false})
: super(name, selfClosing);
int get kind => TokenKind.endTag;
@@ -63,7 +63,7 @@
StringToken(string)
: _string = string,
- _buffer = string == null ? new StringBuffer() : null;
+ _buffer = string == null ? StringBuffer() : null;
StringToken add(String data) {
_buffer.write(data);
@@ -111,7 +111,7 @@
String name = "";
bool correct;
- DoctypeToken({this.publicId, this.systemId, this.correct: false});
+ DoctypeToken({this.publicId, this.systemId, this.correct = false});
int get kind => TokenKind.doctype;
}
diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart
index 30092a2..9f02b6c 100644
--- a/lib/src/tokenizer.dart
+++ b/lib/src/tokenizer.dart
@@ -55,7 +55,7 @@
// bug prevents us from doing that. See http://dartbug.com/12465
Function state;
- final StringBuffer _buffer = new StringBuffer();
+ final StringBuffer _buffer = StringBuffer();
int _lastOffset;
@@ -67,16 +67,15 @@
HtmlTokenizer(doc,
{String encoding,
- bool parseMeta: true,
- this.lowercaseElementName: true,
- this.lowercaseAttrName: true,
- bool generateSpans: false,
+ bool parseMeta = true,
+ this.lowercaseElementName = true,
+ this.lowercaseAttrName = true,
+ this.generateSpans = false,
String sourceUrl,
- this.attributeSpans: false})
- : stream = new HtmlInputStream(
- doc, encoding, parseMeta, generateSpans, sourceUrl),
- tokenQueue = new Queue(),
- generateSpans = generateSpans {
+ this.attributeSpans = false})
+ : stream =
+ HtmlInputStream(doc, encoding, parseMeta, generateSpans, sourceUrl),
+ tokenQueue = Queue() {
reset();
}
@@ -87,8 +86,8 @@
Token _current;
Token get current => _current;
- final StringBuffer _attributeName = new StringBuffer();
- final StringBuffer _attributeValue = new StringBuffer();
+ final StringBuffer _attributeName = StringBuffer();
+ final StringBuffer _attributeValue = StringBuffer();
void _markAttributeEnd(int offset) {
_attributes.last.value = '$_attributeValue';
@@ -112,7 +111,7 @@
_attributeName.clear();
_attributeName.write(name);
_attributeValue.clear();
- var attr = new TagAttribute();
+ var attr = TagAttribute();
_attributes.add(attr);
if (attributeSpans) attr.start = stream.position - name.length;
}
@@ -132,7 +131,7 @@
}
}
if (stream.errors.isNotEmpty) {
- _current = new ParseErrorToken(stream.errors.removeFirst());
+ _current = ParseErrorToken(stream.errors.removeFirst());
} else {
assert(tokenQueue.isNotEmpty);
_current = tokenQueue.removeFirst();
@@ -180,7 +179,7 @@
// Consume all the characters that are in range while making sure we
// don't hit an EOF.
var c = stream.char();
- while (allowed(c) && c != EOF) {
+ while (allowed(c) && c != eof) {
charStack.add(c);
c = stream.char();
}
@@ -191,12 +190,12 @@
// Certain characters get replaced with others
var char = replacementCharacters[charAsInt];
if (char != null) {
- _addToken(new ParseErrorToken("illegal-codepoint-for-numeric-entity",
+ _addToken(ParseErrorToken("illegal-codepoint-for-numeric-entity",
messageParams: {"charAsInt": charAsInt}));
} else if ((0xD800 <= charAsInt && charAsInt <= 0xDFFF) ||
(charAsInt > 0x10FFFF)) {
char = "\uFFFD";
- _addToken(new ParseErrorToken("illegal-codepoint-for-numeric-entity",
+ _addToken(ParseErrorToken("illegal-codepoint-for-numeric-entity",
messageParams: {"charAsInt": charAsInt}));
} else {
// Should speed up this check somehow (e.g. move the set to a constant)
@@ -241,22 +240,22 @@
0x10FFFE,
0x10FFFF
].contains(charAsInt)) {
- _addToken(new ParseErrorToken("illegal-codepoint-for-numeric-entity",
+ _addToken(ParseErrorToken("illegal-codepoint-for-numeric-entity",
messageParams: {"charAsInt": charAsInt}));
}
- char = new String.fromCharCodes([charAsInt]);
+ char = String.fromCharCodes([charAsInt]);
}
// Discard the ; if present. Otherwise, put it back on the queue and
// invoke parseError on parser.
if (c != ";") {
- _addToken(new ParseErrorToken("numeric-entity-without-semicolon"));
+ _addToken(ParseErrorToken("numeric-entity-without-semicolon"));
stream.unget(c);
}
return char;
}
- void consumeEntity({String allowedChar, bool fromAttribute: false}) {
+ void consumeEntity({String allowedChar, bool fromAttribute = false}) {
// Initialise to the default output for when no entity is matched
var output = "&";
@@ -264,7 +263,7 @@
if (isWhitespace(charStack[0]) ||
charStack[0] == '<' ||
charStack[0] == '&' ||
- charStack[0] == EOF ||
+ charStack[0] == eof ||
allowedChar == charStack[0]) {
stream.unget(charStack[0]);
} else if (charStack[0] == "#") {
@@ -284,7 +283,7 @@
output = consumeNumberEntity(hex);
} else {
// No digits found
- _addToken(new ParseErrorToken("expected-numeric-entity"));
+ _addToken(ParseErrorToken("expected-numeric-entity"));
stream.unget(charStack.removeLast());
output = "&${charStack.join()}";
}
@@ -297,7 +296,7 @@
var filteredEntityList = entitiesByFirstChar[charStack[0]];
if (filteredEntityList == null) filteredEntityList = const [];
- while (charStack.last != EOF) {
+ while (charStack.last != eof) {
var name = charStack.join();
filteredEntityList =
filteredEntityList.where((e) => e.startsWith(name)).toList();
@@ -327,7 +326,7 @@
if (entityName != null) {
var lastChar = entityName[entityName.length - 1];
if (lastChar != ";") {
- _addToken(new ParseErrorToken("named-entity-without-semicolon"));
+ _addToken(ParseErrorToken("named-entity-without-semicolon"));
}
if (lastChar != ";" &&
fromAttribute &&
@@ -341,7 +340,7 @@
output = '${output}${slice(charStack, entityLen).join()}';
}
} else {
- _addToken(new ParseErrorToken("expected-named-entity"));
+ _addToken(ParseErrorToken("expected-named-entity"));
stream.unget(charStack.removeLast());
output = "&${charStack.join()}";
}
@@ -351,9 +350,9 @@
} else {
Token token;
if (isWhitespace(output)) {
- token = new SpaceCharactersToken(output);
+ token = SpaceCharactersToken(output);
} else {
- token = new CharactersToken(output);
+ token = CharactersToken(output);
}
_addToken(token);
}
@@ -376,15 +375,15 @@
}
if (token is EndTagToken) {
if (_attributes != null) {
- _addToken(new ParseErrorToken("attributes-in-end-tag"));
+ _addToken(ParseErrorToken("attributes-in-end-tag"));
}
if (token.selfClosing) {
- _addToken(new ParseErrorToken("this-closing-flag-on-end-tag"));
+ _addToken(ParseErrorToken("this-closing-flag-on-end-tag"));
}
} else if (token is StartTagToken) {
// HTML5 specific normalizations to the token stream.
// Convert the list into a map where first key wins.
- token.data = new LinkedHashMap<Object, String>();
+ token.data = LinkedHashMap<Object, String>();
if (_attributes != null) {
for (var attr in _attributes) {
token.data.putIfAbsent(attr.name, () => attr.value);
@@ -408,23 +407,23 @@
} else if (data == "<") {
state = tagOpenState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\u0000"));
- } else if (data == EOF) {
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\u0000"));
+ } else if (data == eof) {
// Tokenization ends.
return false;
} else if (isWhitespace(data)) {
// Directly after emitting a token you switch back to the "data
// state". At that point spaceCharacters are important so they are
// emitted separately.
- _addToken(new SpaceCharactersToken(
+ _addToken(SpaceCharactersToken(
'${data}${stream.charsUntil(spaceCharacters, true)}'));
// No need to update lastFourChars here, since the first space will
// have already been appended to lastFourChars and will have broken
// any <!-- or --> sequences
} else {
var chars = stream.charsUntil("&<\u0000");
- _addToken(new CharactersToken('${data}${chars}'));
+ _addToken(CharactersToken('${data}${chars}'));
}
return true;
}
@@ -441,21 +440,21 @@
state = characterReferenceInRcdata;
} else if (data == "<") {
state = rcdataLessThanSignState;
- } else if (data == EOF) {
+ } else if (data == eof) {
// Tokenization ends.
return false;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
} else if (isWhitespace(data)) {
// Directly after emitting a token you switch back to the "data
// state". At that point spaceCharacters are important so they are
// emitted separately.
- _addToken(new SpaceCharactersToken(
+ _addToken(SpaceCharactersToken(
'${data}${stream.charsUntil(spaceCharacters, true)}'));
} else {
var chars = stream.charsUntil("&<");
- _addToken(new CharactersToken('${data}${chars}'));
+ _addToken(CharactersToken('${data}${chars}'));
}
return true;
}
@@ -471,14 +470,14 @@
if (data == "<") {
state = rawtextLessThanSignState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
- } else if (data == EOF) {
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
+ } else if (data == eof) {
// Tokenization ends.
return false;
} else {
var chars = stream.charsUntil("<\u0000");
- _addToken(new CharactersToken("${data}${chars}"));
+ _addToken(CharactersToken("${data}${chars}"));
}
return true;
}
@@ -488,28 +487,28 @@
if (data == "<") {
state = scriptDataLessThanSignState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
- } else if (data == EOF) {
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
+ } else if (data == eof) {
// Tokenization ends.
return false;
} else {
var chars = stream.charsUntil("<\u0000");
- _addToken(new CharactersToken("${data}${chars}"));
+ _addToken(CharactersToken("${data}${chars}"));
}
return true;
}
bool plaintextState() {
var data = stream.char();
- if (data == EOF) {
+ if (data == eof) {
// Tokenization ends.
return false;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
} else {
- _addToken(new CharactersToken('${data}${stream.charsUntil("\u0000")}'));
+ _addToken(CharactersToken('${data}${stream.charsUntil("\u0000")}'));
}
return true;
}
@@ -521,24 +520,24 @@
} else if (data == "/") {
state = closeTagOpenState;
} else if (isLetter(data)) {
- currentToken = new StartTagToken(data);
+ currentToken = StartTagToken(data);
state = tagNameState;
} else if (data == ">") {
// XXX In theory it could be something besides a tag name. But
// do we really care?
- _addToken(new ParseErrorToken("expected-tag-name-but-got-right-bracket"));
- _addToken(new CharactersToken("<>"));
+ _addToken(ParseErrorToken("expected-tag-name-but-got-right-bracket"));
+ _addToken(CharactersToken("<>"));
state = dataState;
} else if (data == "?") {
// XXX In theory it could be something besides a tag name. But
// do we really care?
- _addToken(new ParseErrorToken("expected-tag-name-but-got-question-mark"));
+ _addToken(ParseErrorToken("expected-tag-name-but-got-question-mark"));
stream.unget(data);
state = bogusCommentState;
} else {
// XXX
- _addToken(new ParseErrorToken("expected-tag-name"));
- _addToken(new CharactersToken("<"));
+ _addToken(ParseErrorToken("expected-tag-name"));
+ _addToken(CharactersToken("<"));
stream.unget(data);
state = dataState;
}
@@ -548,19 +547,18 @@
bool closeTagOpenState() {
var data = stream.char();
if (isLetter(data)) {
- currentToken = new EndTagToken(data);
+ currentToken = EndTagToken(data);
state = tagNameState;
} else if (data == ">") {
- _addToken(
- new ParseErrorToken("expected-closing-tag-but-got-right-bracket"));
+ _addToken(ParseErrorToken("expected-closing-tag-but-got-right-bracket"));
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("expected-closing-tag-but-got-eof"));
- _addToken(new CharactersToken("</"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("expected-closing-tag-but-got-eof"));
+ _addToken(CharactersToken("</"));
state = dataState;
} else {
// XXX data can be _'_...
- _addToken(new ParseErrorToken("expected-closing-tag-but-got-char",
+ _addToken(ParseErrorToken("expected-closing-tag-but-got-char",
messageParams: {"data": data}));
stream.unget(data);
state = bogusCommentState;
@@ -574,13 +572,13 @@
state = beforeAttributeNameState;
} else if (data == ">") {
emitCurrentToken();
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-tag-name"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-tag-name"));
state = dataState;
} else if (data == "/") {
state = selfClosingStartTagState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentTagToken.name = '${currentTagToken.name}\uFFFD';
} else {
currentTagToken.name = '${currentTagToken.name}$data';
@@ -596,7 +594,7 @@
_buffer.clear();
state = rcdataEndTagOpenState;
} else {
- _addToken(new CharactersToken("<"));
+ _addToken(CharactersToken("<"));
stream.unget(data);
state = rcdataState;
}
@@ -609,7 +607,7 @@
_buffer.write(data);
state = rcdataEndTagNameState;
} else {
- _addToken(new CharactersToken("</"));
+ _addToken(CharactersToken("</"));
stream.unget(data);
state = rcdataState;
}
@@ -626,19 +624,19 @@
var appropriate = _tokenIsAppropriate();
var data = stream.char();
if (isWhitespace(data) && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = beforeAttributeNameState;
} else if (data == "/" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = selfClosingStartTagState;
} else if (data == ">" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
emitCurrentToken();
state = dataState;
} else if (isLetter(data)) {
_buffer.write(data);
} else {
- _addToken(new CharactersToken("</$_buffer"));
+ _addToken(CharactersToken("</$_buffer"));
stream.unget(data);
state = rcdataState;
}
@@ -651,7 +649,7 @@
_buffer.clear();
state = rawtextEndTagOpenState;
} else {
- _addToken(new CharactersToken("<"));
+ _addToken(CharactersToken("<"));
stream.unget(data);
state = rawtextState;
}
@@ -664,7 +662,7 @@
_buffer.write(data);
state = rawtextEndTagNameState;
} else {
- _addToken(new CharactersToken("</"));
+ _addToken(CharactersToken("</"));
stream.unget(data);
state = rawtextState;
}
@@ -675,19 +673,19 @@
var appropriate = _tokenIsAppropriate();
var data = stream.char();
if (isWhitespace(data) && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = beforeAttributeNameState;
} else if (data == "/" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = selfClosingStartTagState;
} else if (data == ">" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
emitCurrentToken();
state = dataState;
} else if (isLetter(data)) {
_buffer.write(data);
} else {
- _addToken(new CharactersToken("</$_buffer"));
+ _addToken(CharactersToken("</$_buffer"));
stream.unget(data);
state = rawtextState;
}
@@ -700,10 +698,10 @@
_buffer.clear();
state = scriptDataEndTagOpenState;
} else if (data == "!") {
- _addToken(new CharactersToken("<!"));
+ _addToken(CharactersToken("<!"));
state = scriptDataEscapeStartState;
} else {
- _addToken(new CharactersToken("<"));
+ _addToken(CharactersToken("<"));
stream.unget(data);
state = scriptDataState;
}
@@ -716,7 +714,7 @@
_buffer.write(data);
state = scriptDataEndTagNameState;
} else {
- _addToken(new CharactersToken("</"));
+ _addToken(CharactersToken("</"));
stream.unget(data);
state = scriptDataState;
}
@@ -727,19 +725,19 @@
var appropriate = _tokenIsAppropriate();
var data = stream.char();
if (isWhitespace(data) && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = beforeAttributeNameState;
} else if (data == "/" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = selfClosingStartTagState;
} else if (data == ">" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
emitCurrentToken();
state = dataState;
} else if (isLetter(data)) {
_buffer.write(data);
} else {
- _addToken(new CharactersToken("</$_buffer"));
+ _addToken(CharactersToken("</$_buffer"));
stream.unget(data);
state = scriptDataState;
}
@@ -749,7 +747,7 @@
bool scriptDataEscapeStartState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
state = scriptDataEscapeStartDashState;
} else {
stream.unget(data);
@@ -761,7 +759,7 @@
bool scriptDataEscapeStartDashState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
state = scriptDataEscapedDashDashState;
} else {
stream.unget(data);
@@ -773,18 +771,18 @@
bool scriptDataEscapedState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
state = scriptDataEscapedDashState;
} else if (data == "<") {
state = scriptDataEscapedLessThanSignState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
- } else if (data == EOF) {
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
+ } else if (data == eof) {
state = dataState;
} else {
var chars = stream.charsUntil("<-\u0000");
- _addToken(new CharactersToken("${data}${chars}"));
+ _addToken(CharactersToken("${data}${chars}"));
}
return true;
}
@@ -792,18 +790,18 @@
bool scriptDataEscapedDashState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
state = scriptDataEscapedDashDashState;
} else if (data == "<") {
state = scriptDataEscapedLessThanSignState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
state = scriptDataEscapedState;
- } else if (data == EOF) {
+ } else if (data == eof) {
state = dataState;
} else {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
state = scriptDataEscapedState;
}
return true;
@@ -812,20 +810,20 @@
bool scriptDataEscapedDashDashState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
} else if (data == "<") {
state = scriptDataEscapedLessThanSignState;
} else if (data == ">") {
- _addToken(new CharactersToken(">"));
+ _addToken(CharactersToken(">"));
state = scriptDataState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
state = scriptDataEscapedState;
- } else if (data == EOF) {
+ } else if (data == eof) {
state = dataState;
} else {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
state = scriptDataEscapedState;
}
return true;
@@ -837,12 +835,12 @@
_buffer.clear();
state = scriptDataEscapedEndTagOpenState;
} else if (isLetter(data)) {
- _addToken(new CharactersToken("<$data"));
+ _addToken(CharactersToken("<$data"));
_buffer.clear();
_buffer.write(data);
state = scriptDataDoubleEscapeStartState;
} else {
- _addToken(new CharactersToken("<"));
+ _addToken(CharactersToken("<"));
stream.unget(data);
state = scriptDataEscapedState;
}
@@ -856,7 +854,7 @@
_buffer.write(data);
state = scriptDataEscapedEndTagNameState;
} else {
- _addToken(new CharactersToken("</"));
+ _addToken(CharactersToken("</"));
stream.unget(data);
state = scriptDataEscapedState;
}
@@ -867,19 +865,19 @@
var appropriate = _tokenIsAppropriate();
var data = stream.char();
if (isWhitespace(data) && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = beforeAttributeNameState;
} else if (data == "/" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
state = selfClosingStartTagState;
} else if (data == ">" && appropriate) {
- currentToken = new EndTagToken('$_buffer');
+ currentToken = EndTagToken('$_buffer');
emitCurrentToken();
state = dataState;
} else if (isLetter(data)) {
_buffer.write(data);
} else {
- _addToken(new CharactersToken("</$_buffer"));
+ _addToken(CharactersToken("</$_buffer"));
stream.unget(data);
state = scriptDataEscapedState;
}
@@ -889,14 +887,14 @@
bool scriptDataDoubleEscapeStartState() {
var data = stream.char();
if (isWhitespace(data) || data == "/" || data == ">") {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
if ('$_buffer'.toLowerCase() == "script") {
state = scriptDataDoubleEscapedState;
} else {
state = scriptDataEscapedState;
}
} else if (isLetter(data)) {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
_buffer.write(data);
} else {
stream.unget(data);
@@ -908,19 +906,19 @@
bool scriptDataDoubleEscapedState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
state = scriptDataDoubleEscapedDashState;
} else if (data == "<") {
- _addToken(new CharactersToken("<"));
+ _addToken(CharactersToken("<"));
state = scriptDataDoubleEscapedLessThanSignState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-script-in-script"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-script-in-script"));
state = dataState;
} else {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
}
return true;
}
@@ -928,20 +926,20 @@
bool scriptDataDoubleEscapedDashState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
state = scriptDataDoubleEscapedDashDashState;
} else if (data == "<") {
- _addToken(new CharactersToken("<"));
+ _addToken(CharactersToken("<"));
state = scriptDataDoubleEscapedLessThanSignState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
state = scriptDataDoubleEscapedState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-script-in-script"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-script-in-script"));
state = dataState;
} else {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
state = scriptDataDoubleEscapedState;
}
return true;
@@ -952,22 +950,22 @@
bool scriptDataDoubleEscapedDashDashState() {
var data = stream.char();
if (data == "-") {
- _addToken(new CharactersToken("-"));
+ _addToken(CharactersToken("-"));
} else if (data == "<") {
- _addToken(new CharactersToken("<"));
+ _addToken(CharactersToken("<"));
state = scriptDataDoubleEscapedLessThanSignState;
} else if (data == ">") {
- _addToken(new CharactersToken(">"));
+ _addToken(CharactersToken(">"));
state = scriptDataState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
- _addToken(new CharactersToken("\uFFFD"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
+ _addToken(CharactersToken("\uFFFD"));
state = scriptDataDoubleEscapedState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-script-in-script"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-script-in-script"));
state = dataState;
} else {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
state = scriptDataDoubleEscapedState;
}
return true;
@@ -976,7 +974,7 @@
bool scriptDataDoubleEscapedLessThanSignState() {
var data = stream.char();
if (data == "/") {
- _addToken(new CharactersToken("/"));
+ _addToken(CharactersToken("/"));
_buffer.clear();
state = scriptDataDoubleEscapeEndState;
} else {
@@ -989,14 +987,14 @@
bool scriptDataDoubleEscapeEndState() {
var data = stream.char();
if (isWhitespace(data) || data == "/" || data == ">") {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
if ('$_buffer'.toLowerCase() == "script") {
state = scriptDataEscapedState;
} else {
state = scriptDataDoubleEscapedState;
}
} else if (isLetter(data)) {
- _addToken(new CharactersToken(data));
+ _addToken(CharactersToken(data));
_buffer.write(data);
} else {
stream.unget(data);
@@ -1016,15 +1014,15 @@
emitCurrentToken();
} else if (data == "/") {
state = selfClosingStartTagState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("expected-attribute-name-but-got-eof"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("expected-attribute-name-but-got-eof"));
state = dataState;
} else if ("'\"=<".contains(data)) {
- _addToken(new ParseErrorToken("invalid-character-in-attribute-name"));
+ _addToken(ParseErrorToken("invalid-character-in-attribute-name"));
_addAttribute(data);
state = attributeNameState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
_addAttribute("\uFFFD");
state = attributeNameState;
} else {
@@ -1054,14 +1052,14 @@
} else if (data == "/") {
state = selfClosingStartTagState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
_attributeName.write('\uFFFD');
leavingThisState = false;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-attribute-name"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-attribute-name"));
state = dataState;
} else if ("'\"<".contains(data)) {
- _addToken(new ParseErrorToken("invalid-character-in-attribute-name"));
+ _addToken(ParseErrorToken("invalid-character-in-attribute-name"));
_attributeName.write(data);
leavingThisState = false;
} else {
@@ -1080,9 +1078,9 @@
attrName = asciiUpper2Lower(attrName);
}
_attributes.last.name = attrName;
- if (_attributeNames == null) _attributeNames = new Set();
+ if (_attributeNames == null) _attributeNames = Set();
if (_attributeNames.contains(attrName)) {
- _addToken(new ParseErrorToken("duplicate-attribute"));
+ _addToken(ParseErrorToken("duplicate-attribute"));
}
_attributeNames.add(attrName);
@@ -1108,14 +1106,14 @@
} else if (data == "/") {
state = selfClosingStartTagState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
_addAttribute("\uFFFD");
state = attributeNameState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("expected-end-of-tag-but-got-eof"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("expected-end-of-tag-but-got-eof"));
state = dataState;
} else if ("'\"<".contains(data)) {
- _addToken(new ParseErrorToken("invalid-character-after-attribute-name"));
+ _addToken(ParseErrorToken("invalid-character-after-attribute-name"));
_addAttribute(data);
state = attributeNameState;
} else {
@@ -1140,19 +1138,19 @@
_markAttributeValueStart(0);
state = attributeValueSingleQuotedState;
} else if (data == ">") {
- _addToken(new ParseErrorToken(
- "expected-attribute-value-but-got-right-bracket"));
+ _addToken(
+ ParseErrorToken("expected-attribute-value-but-got-right-bracket"));
emitCurrentToken();
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
_markAttributeValueStart(-1);
_attributeValue.write('\uFFFD');
state = attributeValueUnQuotedState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("expected-attribute-value-but-got-eof"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("expected-attribute-value-but-got-eof"));
state = dataState;
} else if ("=<`".contains(data)) {
- _addToken(new ParseErrorToken("equals-in-unquoted-attribute-value"));
+ _addToken(ParseErrorToken("equals-in-unquoted-attribute-value"));
_markAttributeValueStart(-1);
_attributeValue.write(data);
state = attributeValueUnQuotedState;
@@ -1173,10 +1171,10 @@
} else if (data == "&") {
processEntityInAttribute('"');
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
_attributeValue.write('\uFFFD');
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-attribute-value-double-quote"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-attribute-value-double-quote"));
_markAttributeValueEnd(-1);
state = dataState;
} else {
@@ -1195,10 +1193,10 @@
} else if (data == "&") {
processEntityInAttribute("'");
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
_attributeValue.write('\uFFFD');
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-attribute-value-single-quote"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-attribute-value-single-quote"));
_markAttributeValueEnd(-1);
state = dataState;
} else {
@@ -1218,16 +1216,16 @@
} else if (data == ">") {
_markAttributeValueEnd(-1);
emitCurrentToken();
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-attribute-value-no-quotes"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-attribute-value-no-quotes"));
_markAttributeValueEnd(-1);
state = dataState;
} else if ('"\'=<`'.contains(data)) {
- _addToken(new ParseErrorToken(
- "unexpected-character-in-unquoted-attribute-value"));
+ _addToken(
+ ParseErrorToken("unexpected-character-in-unquoted-attribute-value"));
_attributeValue.write(data);
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
_attributeValue.write('\uFFFD');
} else {
_attributeValue.write(data);
@@ -1244,13 +1242,12 @@
emitCurrentToken();
} else if (data == "/") {
state = selfClosingStartTagState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("unexpected-EOF-after-attribute-value"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("unexpected-EOF-after-attribute-value"));
stream.unget(data);
state = dataState;
} else {
- _addToken(
- new ParseErrorToken("unexpected-character-after-attribute-value"));
+ _addToken(ParseErrorToken("unexpected-character-after-attribute-value"));
stream.unget(data);
state = beforeAttributeNameState;
}
@@ -1262,13 +1259,12 @@
if (data == ">") {
currentTagToken.selfClosing = true;
emitCurrentToken();
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("unexpected-EOF-after-solidus-in-tag"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("unexpected-EOF-after-solidus-in-tag"));
stream.unget(data);
state = dataState;
} else {
- _addToken(
- new ParseErrorToken("unexpected-character-after-soldius-in-tag"));
+ _addToken(ParseErrorToken("unexpected-character-after-soldius-in-tag"));
stream.unget(data);
state = beforeAttributeNameState;
}
@@ -1281,7 +1277,7 @@
// and emit it.
var data = stream.charsUntil(">");
data = data.replaceAll("\u0000", "\uFFFD");
- _addToken(new CommentToken(data));
+ _addToken(CommentToken(data));
// Eat the character directly after the bogus comment which is either a
// ">" or an EOF.
@@ -1295,7 +1291,7 @@
if (charStack.last == "-") {
charStack.add(stream.char());
if (charStack.last == "-") {
- currentToken = new CommentToken();
+ currentToken = CommentToken();
state = commentStartState;
return true;
}
@@ -1304,13 +1300,13 @@
for (var expected in const ['oO', 'cC', 'tT', 'yY', 'pP', 'eE']) {
var char = stream.char();
charStack.add(char);
- if (char == EOF || !expected.contains(char)) {
+ if (char == eof || !expected.contains(char)) {
matched = false;
break;
}
}
if (matched) {
- currentToken = new DoctypeToken(correct: true);
+ currentToken = DoctypeToken(correct: true);
state = doctypeState;
return true;
}
@@ -1333,7 +1329,7 @@
}
}
- _addToken(new ParseErrorToken("expected-dashes-or-doctype"));
+ _addToken(ParseErrorToken("expected-dashes-or-doctype"));
while (charStack.isNotEmpty) {
stream.unget(charStack.removeLast());
@@ -1347,14 +1343,14 @@
if (data == "-") {
state = commentStartDashState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentStringToken.add('\uFFFD');
} else if (data == ">") {
- _addToken(new ParseErrorToken("incorrect-comment"));
+ _addToken(ParseErrorToken("incorrect-comment"));
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-comment"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-comment"));
_addToken(currentToken);
state = dataState;
} else {
@@ -1369,14 +1365,14 @@
if (data == "-") {
state = commentEndState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentStringToken.add('-\uFFFD');
} else if (data == ">") {
- _addToken(new ParseErrorToken("incorrect-comment"));
+ _addToken(ParseErrorToken("incorrect-comment"));
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-comment"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-comment"));
_addToken(currentToken);
state = dataState;
} else {
@@ -1391,10 +1387,10 @@
if (data == "-") {
state = commentEndDashState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentStringToken.add('\uFFFD');
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-comment"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-comment"));
_addToken(currentToken);
state = dataState;
} else {
@@ -1408,11 +1404,11 @@
if (data == "-") {
state = commentEndState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentStringToken.add('-\uFFFD');
state = commentState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-comment-end-dash"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-comment-end-dash"));
_addToken(currentToken);
state = dataState;
} else {
@@ -1428,24 +1424,24 @@
_addToken(currentToken);
state = dataState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentStringToken.add('--\uFFFD');
state = commentState;
} else if (data == "!") {
_addToken(
- new ParseErrorToken("unexpected-bang-after-double-dash-in-comment"));
+ ParseErrorToken("unexpected-bang-after-double-dash-in-comment"));
state = commentEndBangState;
} else if (data == "-") {
_addToken(
- new ParseErrorToken("unexpected-dash-after-double-dash-in-comment"));
+ ParseErrorToken("unexpected-dash-after-double-dash-in-comment"));
currentStringToken.add(data);
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-comment-double-dash"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-comment-double-dash"));
_addToken(currentToken);
state = dataState;
} else {
// XXX
- _addToken(new ParseErrorToken("unexpected-char-in-comment"));
+ _addToken(ParseErrorToken("unexpected-char-in-comment"));
currentStringToken.add('--').add(data);
state = commentState;
}
@@ -1461,11 +1457,11 @@
currentStringToken.add('--!');
state = commentEndDashState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentStringToken.add('--!\uFFFD');
state = commentState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-comment-end-bang-state"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-comment-end-bang-state"));
_addToken(currentToken);
state = dataState;
} else {
@@ -1479,13 +1475,13 @@
var data = stream.char();
if (isWhitespace(data)) {
state = beforeDoctypeNameState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("expected-doctype-name-but-got-eof"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("expected-doctype-name-but-got-eof"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
} else {
- _addToken(new ParseErrorToken("need-space-after-doctype"));
+ _addToken(ParseErrorToken("need-space-after-doctype"));
stream.unget(data);
state = beforeDoctypeNameState;
}
@@ -1497,17 +1493,16 @@
if (isWhitespace(data)) {
return true;
} else if (data == ">") {
- _addToken(
- new ParseErrorToken("expected-doctype-name-but-got-right-bracket"));
+ _addToken(ParseErrorToken("expected-doctype-name-but-got-right-bracket"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentDoctypeToken.name = "\uFFFD";
state = doctypeNameState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("expected-doctype-name-but-got-eof"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("expected-doctype-name-but-got-eof"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
@@ -1528,11 +1523,11 @@
_addToken(currentToken);
state = dataState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentDoctypeToken.name = "${currentDoctypeToken.name}\uFFFD";
state = doctypeNameState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype-name"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype-name"));
currentDoctypeToken.correct = false;
currentDoctypeToken.name = asciiUpper2Lower(currentDoctypeToken.name);
_addToken(currentToken);
@@ -1550,10 +1545,10 @@
} else if (data == ">") {
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
+ } else if (data == eof) {
currentDoctypeToken.correct = false;
stream.unget(data);
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ _addToken(ParseErrorToken("eof-in-doctype"));
_addToken(currentToken);
state = dataState;
} else {
@@ -1562,7 +1557,7 @@
var matched = true;
for (var expected in const ["uU", "bB", "lL", "iI", "cC"]) {
data = stream.char();
- if (data == EOF || !expected.contains(data)) {
+ if (data == eof || !expected.contains(data)) {
matched = false;
break;
}
@@ -1575,7 +1570,7 @@
var matched = true;
for (var expected in const ["yY", "sS", "tT", "eE", "mM"]) {
data = stream.char();
- if (data == EOF || !expected.contains(data)) {
+ if (data == eof || !expected.contains(data)) {
matched = false;
break;
}
@@ -1591,8 +1586,7 @@
// discarded; only the latest character might be '>' or EOF
// and needs to be ungetted
stream.unget(data);
- _addToken(new ParseErrorToken(
- "expected-space-or-right-bracket-in-doctype",
+ _addToken(ParseErrorToken("expected-space-or-right-bracket-in-doctype",
messageParams: {"data": data}));
currentDoctypeToken.correct = false;
state = bogusDoctypeState;
@@ -1605,11 +1599,11 @@
if (isWhitespace(data)) {
state = beforeDoctypePublicIdentifierState;
} else if (data == "'" || data == '"') {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
stream.unget(data);
state = beforeDoctypePublicIdentifierState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
@@ -1631,17 +1625,17 @@
currentDoctypeToken.publicId = "";
state = doctypePublicIdentifierSingleQuotedState;
} else if (data == ">") {
- _addToken(new ParseErrorToken("unexpected-end-of-doctype"));
+ _addToken(ParseErrorToken("unexpected-end-of-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
} else {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
currentDoctypeToken.correct = false;
state = bogusDoctypeState;
}
@@ -1653,15 +1647,15 @@
if (data == '"') {
state = afterDoctypePublicIdentifierState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentDoctypeToken.publicId = "${currentDoctypeToken.publicId}\uFFFD";
} else if (data == ">") {
- _addToken(new ParseErrorToken("unexpected-end-of-doctype"));
+ _addToken(ParseErrorToken("unexpected-end-of-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
@@ -1676,15 +1670,15 @@
if (data == "'") {
state = afterDoctypePublicIdentifierState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentDoctypeToken.publicId = "${currentDoctypeToken.publicId}\uFFFD";
} else if (data == ">") {
- _addToken(new ParseErrorToken("unexpected-end-of-doctype"));
+ _addToken(ParseErrorToken("unexpected-end-of-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
@@ -1702,20 +1696,20 @@
_addToken(currentToken);
state = dataState;
} else if (data == '"') {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
currentDoctypeToken.systemId = "";
state = doctypeSystemIdentifierDoubleQuotedState;
} else if (data == "'") {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
currentDoctypeToken.systemId = "";
state = doctypeSystemIdentifierSingleQuotedState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
} else {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
currentDoctypeToken.correct = false;
state = bogusDoctypeState;
}
@@ -1735,13 +1729,13 @@
} else if (data == "'") {
currentDoctypeToken.systemId = "";
state = doctypeSystemIdentifierSingleQuotedState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
} else {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
currentDoctypeToken.correct = false;
state = bogusDoctypeState;
}
@@ -1753,11 +1747,11 @@
if (isWhitespace(data)) {
state = beforeDoctypeSystemIdentifierState;
} else if (data == "'" || data == '"') {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
stream.unget(data);
state = beforeDoctypeSystemIdentifierState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
@@ -1779,17 +1773,17 @@
currentDoctypeToken.systemId = "";
state = doctypeSystemIdentifierSingleQuotedState;
} else if (data == ">") {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
} else {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
currentDoctypeToken.correct = false;
state = bogusDoctypeState;
}
@@ -1801,15 +1795,15 @@
if (data == "\"") {
state = afterDoctypeSystemIdentifierState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentDoctypeToken.systemId = "${currentDoctypeToken.systemId}\uFFFD";
} else if (data == ">") {
- _addToken(new ParseErrorToken("unexpected-end-of-doctype"));
+ _addToken(ParseErrorToken("unexpected-end-of-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
@@ -1824,15 +1818,15 @@
if (data == "'") {
state = afterDoctypeSystemIdentifierState;
} else if (data == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
currentDoctypeToken.systemId = "${currentDoctypeToken.systemId}\uFFFD";
} else if (data == ">") {
- _addToken(new ParseErrorToken("unexpected-end-of-doctype"));
+ _addToken(ParseErrorToken("unexpected-end-of-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
@@ -1849,13 +1843,13 @@
} else if (data == ">") {
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
- _addToken(new ParseErrorToken("eof-in-doctype"));
+ } else if (data == eof) {
+ _addToken(ParseErrorToken("eof-in-doctype"));
currentDoctypeToken.correct = false;
_addToken(currentToken);
state = dataState;
} else {
- _addToken(new ParseErrorToken("unexpected-char-in-doctype"));
+ _addToken(ParseErrorToken("unexpected-char-in-doctype"));
state = bogusDoctypeState;
}
return true;
@@ -1866,7 +1860,7 @@
if (data == ">") {
_addToken(currentToken);
state = dataState;
- } else if (data == EOF) {
+ } else if (data == eof) {
// XXX EMIT
stream.unget(data);
_addToken(currentToken);
@@ -1880,12 +1874,12 @@
int matchedEnd = 0;
while (true) {
var ch = stream.char();
- if (ch == EOF) {
+ if (ch == eof) {
break;
}
// Deal with null here rather than in the parser
if (ch == "\u0000") {
- _addToken(new ParseErrorToken("invalid-codepoint"));
+ _addToken(ParseErrorToken("invalid-codepoint"));
ch = "\uFFFD";
}
data.add(ch);
@@ -1905,7 +1899,7 @@
}
if (data.isNotEmpty) {
- _addToken(new CharactersToken(data.join()));
+ _addToken(CharactersToken(data.join()));
}
state = dataState;
return true;
diff --git a/lib/src/treebuilder.dart b/lib/src/treebuilder.dart
index 12cdbbb..f6db7ad 100644
--- a/lib/src/treebuilder.dart
+++ b/lib/src/treebuilder.dart
@@ -72,7 +72,7 @@
final List<Element> openElements = <Element>[];
- final activeFormattingElements = new ActiveFormattingElements();
+ final activeFormattingElements = ActiveFormattingElements();
Node headPointer;
@@ -97,7 +97,7 @@
insertFromTable = false;
- document = new Document();
+ document = Document();
}
bool elementInScope(target, {String variant}) {
@@ -111,29 +111,29 @@
if (variant != null) {
switch (variant) {
case "button":
- listElements2 = const [const Pair(Namespaces.html, "button")];
+ listElements2 = const [Pair(Namespaces.html, "button")];
break;
case "list":
listElements2 = const [
- const Pair(Namespaces.html, "ol"),
- const Pair(Namespaces.html, "ul")
+ Pair(Namespaces.html, "ol"),
+ Pair(Namespaces.html, "ul")
];
break;
case "table":
listElements1 = const [
- const Pair(Namespaces.html, "html"),
- const Pair(Namespaces.html, "table")
+ Pair(Namespaces.html, "html"),
+ Pair(Namespaces.html, "table")
];
break;
case "select":
listElements1 = const [
- const Pair(Namespaces.html, "optgroup"),
- const Pair(Namespaces.html, "option")
+ Pair(Namespaces.html, "optgroup"),
+ Pair(Namespaces.html, "option")
];
invert = true;
break;
default:
- throw new StateError('We should never reach this point');
+ throw StateError('We should never reach this point');
}
}
@@ -148,7 +148,7 @@
}
}
- throw new StateError('We should never reach this point');
+ throw StateError('We should never reach this point');
}
void reconstructActiveFormattingElements() {
@@ -188,9 +188,9 @@
entry = activeFormattingElements[i];
// TODO(jmesserly): optimize this. No need to create a token.
- var cloneToken = new StartTagToken(entry.localName,
+ var cloneToken = StartTagToken(entry.localName,
namespace: entry.namespaceUri,
- data: new LinkedHashMap.from(entry.attributes))
+ data: LinkedHashMap.from(entry.attributes))
..span = entry.sourceSpan;
// Step 9
@@ -236,7 +236,7 @@
}
void insertDoctype(DoctypeToken token) {
- var doctype = new DocumentType(token.name, token.publicId, token.systemId)
+ var doctype = DocumentType(token.name, token.publicId, token.systemId)
..sourceSpan = token.span;
document.nodes.add(doctype);
}
@@ -245,7 +245,7 @@
if (parent == null) {
parent = openElements.last;
}
- parent.nodes.add(new Comment(token.data)..sourceSpan = token.span);
+ parent.nodes.add(Comment(token.data)..sourceSpan = token.span);
}
/// Create an element but don't insert it anywhere
@@ -329,7 +329,7 @@
span.file.span(last.sourceSpan.start.offset, span.end.offset);
}
} else {
- nodes.add(new Text(data)..sourceSpan = span);
+ nodes.add(Text(data)..sourceSpan = span);
}
} else {
int index = nodes.indexOf(refNode);
@@ -337,7 +337,7 @@
Text last = nodes[index - 1];
last.appendData(data);
} else {
- nodes.insert(index, new Text(data)..sourceSpan = span);
+ nodes.insert(index, Text(data)..sourceSpan = span);
}
}
}
@@ -391,7 +391,7 @@
/// Return the final fragment.
DocumentFragment getFragment() {
//XXX assert innerHTML
- var fragment = new DocumentFragment();
+ var fragment = DocumentFragment();
openElements[0].reparentChildren(fragment);
return fragment;
}
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 909b899..6d25b59 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -12,6 +12,7 @@
const Pair(this.first, this.second);
int get hashCode => 37 * first.hashCode + second.hashCode;
+
bool operator ==(other) => other.first == first && other.second == second;
}
@@ -62,7 +63,7 @@
String padWithZeros(String str, int size) {
if (str.length == size) return str;
- var result = new StringBuffer();
+ var result = StringBuffer();
size -= str.length;
for (int i = 0; i < size; i++) result.write('0');
result.write(str);
@@ -77,9 +78,11 @@
String formatStr(String format, Map data) {
if (data == null) return format;
data.forEach((key, value) {
- var result = new StringBuffer();
+ var result = StringBuffer();
var search = '%($key)';
int last = 0, match;
+ // This is a bug in the linter
+ // ignore: prefer_contains
while ((match = format.indexOf(search, last)) >= 0) {
result.write(format.substring(last, match));
match += search.length;
@@ -107,8 +110,8 @@
result.write(padWithZeros(number, numberSize));
break;
default:
- throw "not implemented: formatStr does not support format "
- "character ${format[match]}";
+ throw UnsupportedError("formatStr does not support format "
+ "character ${format[match]}");
}
last = match + 1;
diff --git a/pubspec.yaml b/pubspec.yaml
index 7aeb9ba..3a43cda 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,12 +1,12 @@
name: html
-version: 0.13.3+3
+version: 0.13.4-dev
-description: A library for working with HTML documents. Previously known as html5lib.
+description: A library for working with HTML documents.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/html
environment:
- sdk: '>=2.0.0-dev.17.0 <3.0.0'
+ sdk: '>=2.0.0 <3.0.0'
dependencies:
csslib: '>=0.13.2 <0.15.0'
@@ -15,4 +15,5 @@
dev_dependencies:
path: ^1.6.2
+ pedantic: ^1.3.0
test: ^1.3.0
diff --git a/test/dom_test.dart b/test/dom_test.dart
index 671d0b1..1cf912e 100644
--- a/test/dom_test.dart
+++ b/test/dom_test.dart
@@ -8,8 +8,8 @@
main() {
group('Element', () {
test('classes', () {
- final barBaz = new Element.html('<div class=" bar baz"></div>');
- final quxBaz = new Element.html('<div class="qux baz "></div>');
+ final barBaz = Element.html('<div class=" bar baz"></div>');
+ final quxBaz = Element.html('<div class="qux baz "></div>');
expect(barBaz.className, ' bar baz');
expect(quxBaz.className, 'qux baz ');
expect(barBaz.classes, ['bar', 'baz']);
@@ -25,11 +25,11 @@
test('getElementById', () {
var foo = doc.body.nodes[0];
- var Foo = foo.nodes[2];
+ var fooVar = foo.nodes[2];
expect((foo as Element).id, 'foo');
- expect((Foo as Element).id, 'Foo');
+ expect((fooVar as Element).id, 'Foo');
expect(doc.getElementById('foo'), foo);
- expect(doc.getElementById('Foo'), Foo);
+ expect(doc.getElementById('Foo'), fooVar);
});
test('getElementsByClassName', () {
@@ -48,8 +48,8 @@
var foo = doc.body.nodes[0];
var barBaz = foo.nodes[0];
var quxBaz = foo.nodes[1];
- var Foo = foo.nodes[2];
- expect(doc.getElementsByTagName('div'), [foo, barBaz, quxBaz, Foo]);
+ var fooVar = foo.nodes[2];
+ expect(doc.getElementsByTagName('div'), [foo, barBaz, quxBaz, fooVar]);
});
});
diff --git a/test/parser_feature_test.dart b/test/parser_feature_test.dart
index 45c704c..c112717 100644
--- a/test/parser_feature_test.dart
+++ b/test/parser_feature_test.dart
@@ -24,17 +24,17 @@
});
test('namespace html elements on', () {
- var doc = new HtmlParser('', tree: new TreeBuilder(true)).parse();
+ var doc = HtmlParser('', tree: TreeBuilder(true)).parse();
expect((doc.nodes[0] as Element).namespaceUri, Namespaces.html);
});
test('namespace html elements off', () {
- var doc = new HtmlParser('', tree: new TreeBuilder(false)).parse();
+ var doc = HtmlParser('', tree: TreeBuilder(false)).parse();
expect((doc.nodes[0] as Element).namespaceUri, null);
});
test('parse error spans - full', () {
- var parser = new HtmlParser('''
+ var parser = HtmlParser('''
<!DOCTYPE html>
<html>
<body>
@@ -62,7 +62,7 @@
});
test('parse error spans - minimal', () {
- var parser = new HtmlParser('''
+ var parser = HtmlParser('''
<!DOCTYPE html>
<html>
<body>
@@ -85,7 +85,7 @@
var html = '<body><div>$textContent</div>';
var doc = parse(html, generateSpans: true);
Text text = doc.body.nodes[0].nodes[0];
- expect(text, new TypeMatcher<Text>());
+ expect(text, const TypeMatcher<Text>());
expect(text.data, textContent);
expect(text.sourceSpan.start.offset, html.indexOf(textContent));
expect(text.sourceSpan.length, textContent.length);
@@ -229,7 +229,7 @@
''');
var n = doc.querySelector('desc');
var keys = n.attributes.keys.toList();
- expect(keys[0], new TypeMatcher<AttributeName>());
+ expect(keys[0], const TypeMatcher<AttributeName>());
expect(keys[0].prefix, 'xlink');
expect(keys[0].namespace, 'http://www.w3.org/1999/xlink');
expect(keys[0].name, 'type');
@@ -242,7 +242,7 @@
});
test('error printing without spans', () {
- var parser = new HtmlParser('foo');
+ var parser = HtmlParser('foo');
var doc = parser.parse();
expect(doc.body.innerHtml, 'foo');
expect(parser.errors.length, 1);
@@ -299,7 +299,7 @@
});
test('foreignObject end tag', () {
- var p = new HtmlParser('''
+ var p = HtmlParser('''
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
version="1.1">
<foreignObject width="320px" height="200px">
@@ -313,7 +313,7 @@
});
group('Encoding pre-parser', () {
- getEncoding(String s) => new EncodingParser(s.codeUnits).getEncoding();
+ getEncoding(String s) => EncodingParser(s.codeUnits).getEncoding();
test('gets encoding from meta charset', () {
expect(getEncoding('<meta charset="utf-16">'), 'utf-16');
diff --git a/test/parser_test.dart b/test/parser_test.dart
index c0a96cb..1289f61 100644
--- a/test/parser_test.dart
+++ b/test/parser_test.dart
@@ -20,7 +20,7 @@
// We can't do regex replace directly =\
// final namespaceExpected = new RegExp(@"^(\s*)<(\S+)>", multiLine: true);
// return expected.replaceAll(namespaceExpected, @"$1<html $2>");
- final namespaceExpected = new RegExp(r"^(\|\s*)<(\S+)>");
+ final namespaceExpected = RegExp(r"^(\|\s*)<(\S+)>");
var lines = expected.split("\n");
for (int i = 0; i < lines.length; i++) {
var match = namespaceExpected.firstMatch(lines[i]);
@@ -42,7 +42,7 @@
// XXX - move this out into the setup function
// concatenate all consecutive character tokens into a single token
var builder = treeCtor(namespaceHTMLElements);
- var parser = new HtmlParser(input, tree: builder);
+ var parser = HtmlParser(input, tree: builder);
Node document;
if (innerHTML != null) {
@@ -74,9 +74,9 @@
test('dart:io', () {
// ensure IO support is unregistered
expect(inputstream.consoleSupport,
- new TypeMatcher<inputstream.ConsoleSupport>());
- var file = new File('$testDataDir/parser_feature/raw_file.html').openSync();
- expect(() => parse(file), throwsA(new TypeMatcher<ArgumentError>()));
+ const TypeMatcher<inputstream.ConsoleSupport>());
+ var file = File('$testDataDir/parser_feature/raw_file.html').openSync();
+ expect(() => parse(file), throwsA(const TypeMatcher<ArgumentError>()));
parser_console.useConsole();
expect(parse(file).body.innerHtml.trim(), 'Hello world!');
});
@@ -84,7 +84,7 @@
for (var path in getDataFiles('tree-construction')) {
if (!path.endsWith('.dat')) continue;
- var tests = new TestData(path, "data");
+ var tests = TestData(path, "data");
var testName = pathos.basenameWithoutExtension(path);
group(testName, () {
@@ -114,9 +114,9 @@
_nameFor(String input) {
// Using jsonDecode to unescape other unicode characters
var escapeQuote = input
- .replaceAll(new RegExp('\\\\.'), '_')
- .replaceAll(new RegExp('\u0000'), '_')
+ .replaceAll(RegExp('\\\\.'), '_')
+ .replaceAll(RegExp('\u0000'), '_')
.replaceAll('"', '\\"')
- .replaceAll(new RegExp('[\n\r\t]'), '_');
+ .replaceAll(RegExp('[\n\r\t]'), '_');
return jsonDecode('"$escapeQuote"');
}
diff --git a/test/selectors/level1_baseline_test.dart b/test/selectors/level1_baseline_test.dart
index 9066842..7ed1cc4 100644
--- a/test/selectors/level1_baseline_test.dart
+++ b/test/selectors/level1_baseline_test.dart
@@ -19,10 +19,10 @@
Document getTestContentDocument() {
var testPath = p.join(testDir, 'selectors', 'level1-content.html');
- return parse(new File(testPath).readAsStringSync());
+ return parse(File(testPath).readAsStringSync());
}
-var testType = TEST_QSA_BASELINE; // Only run baseline tests.
+var testType = testQsaBaseline; // Only run baseline tests.
var docType = "html"; // Only run tests suitable for HTML
main() {
diff --git a/test/selectors/level1_lib.dart b/test/selectors/level1_lib.dart
index 4ffa9a8..d87c795 100644
--- a/test/selectors/level1_lib.dart
+++ b/test/selectors/level1_lib.dart
@@ -208,7 +208,7 @@
nodeType = "fragment";
break;
default:
- throw new StateError("Reached unreachable code path.");
+ throw StateError("Reached unreachable code path.");
}
for (var i = 0; i < selectors.length; i++) {
diff --git a/test/selectors/selectors.dart b/test/selectors/selectors.dart
index d25b14b..9810f5f 100644
--- a/test/selectors/selectors.dart
+++ b/test/selectors/selectors.dart
@@ -3,16 +3,16 @@
library html.test.selectors.selectors;
// Bit-mapped flags to indicate which tests the selector is suitable for
-var TEST_QSA_BASELINE =
+final testQsaBaseline =
0x01; // querySelector() and querySelectorAll() baseline tests
-var TEST_QSA_ADDITIONAL =
+final testQsaAdditional =
0x02; // querySelector() and querySelectorAll() additional tests
-var TEST_FIND_BASELINE =
+final testFindBaseline =
0x04; // find() and findAll() baseline tests, may be unsuitable for querySelector[All]
-var TEST_FIND_ADDITIONAL =
+final testFindAdditional =
0x08; // find() and findAll() additional tests, may be unsuitable for querySelector[All]
-var TEST_MATCH_BASELINE = 0x10; // matches() baseline tests
-var TEST_MATCH_ADDITIONAL = 0x20; // matches() additional tests
+final testMatchBaseline = 0x10; // matches() baseline tests
+var testMatchAdditional = 0x20; // matches() additional tests
/*
* All of these invalid selectors should result in a SyntaxError being thrown by the APIs.
@@ -20,7 +20,7 @@
* name: A descriptive name of the selector being tested
* selector: The selector to test
*/
-var invalidSelectors = [
+final invalidSelectors = [
{'name': "Empty String", 'selector': ""},
{'name': "Invalid character", 'selector': "["},
{'name': "Invalid character", 'selector': "]"},
@@ -82,7 +82,7 @@
'expect': ["html"],
'exclude': ["element", "fragment", "detached"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Type selector, matching html element",
@@ -90,7 +90,7 @@
'expect': [] /*no matches*/,
'exclude': ["document"],
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "Type selector, matching body element",
@@ -98,7 +98,7 @@
'expect': ["body"],
'exclude': ["element", "fragment", "detached"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Type selector, matching body element",
@@ -106,7 +106,7 @@
'expect': [] /*no matches*/,
'exclude': ["document"],
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
// Universal Selector
@@ -123,7 +123,7 @@
"universal-address1"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -136,7 +136,7 @@
"universal-code2"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -144,7 +144,7 @@
'selector': "#empty>*",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -163,7 +163,7 @@
"universal-a2"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// Attribute Selectors
@@ -173,7 +173,7 @@
'selector': ".attr-presence-div1[align]",
'expect': ["attr-presence-div1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -181,7 +181,7 @@
'selector': ".attr-presence-div2[align]",
'expect': ["attr-presence-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -190,7 +190,7 @@
'expect': ["attr-presence-a1", "attr-presence-span1"],
'exclude': ["xhtml"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -199,14 +199,14 @@
'expect': [],
'exclude': ["html"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Attribute presence selector, matching custom data-* attribute",
'selector': "[data-attr-presence]",
'expect': ["attr-presence-pre1", "attr-presence-blockquote1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -214,7 +214,7 @@
'selector': ".attr-presence-div3[align], .attr-presence-div4[align]",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -222,7 +222,7 @@
'selector': "ul[data-中文]",
'expect': ["attr-presence-ul1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -230,7 +230,7 @@
'selector': "#attr-presence-select1 option[selected]",
'expect': [] /* no matches */,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -238,7 +238,7 @@
'selector': "#attr-presence-select2 option[selected]",
'expect': ["attr-presence-select2-option4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -249,7 +249,7 @@
"attr-presence-select3-option3"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// - value [att=val]
@@ -258,7 +258,7 @@
'selector': "#attr-value [align=\"center\"]",
'expect': ["attr-value-div1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -266,7 +266,7 @@
'selector': "#attr-value [align=\"\"]",
'expect': ["attr-value-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -274,7 +274,7 @@
'selector': "#attr-value [align=\"c\"]",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -282,7 +282,7 @@
'selector': "#attr-value [align=\"centera\"]",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -290,7 +290,7 @@
'selector': "[data-attr-value=\"\\e9\"]",
'expect': ["attr-value-div3"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -298,7 +298,7 @@
'selector': "[data-attr-value\_foo=\"\\e9\"]",
'expect': ["attr-value-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -313,7 +313,7 @@
"attr-value-input9"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -328,7 +328,7 @@
"attr-value-input9"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -342,7 +342,7 @@
"attr-value-input9"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -350,7 +350,7 @@
'selector': "[data-attr-value=中文]",
'expect': ["attr-value-div5"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// - whitespace-separated list [att~=val]
@@ -360,7 +360,7 @@
'selector': "#attr-whitespace [class~=\"div1\"]",
'expect': ["attr-whitespace-div1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -368,7 +368,7 @@
'selector': "#attr-whitespace [class~=\"\"]",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -376,7 +376,7 @@
'selector': "[data-attr-whitespace~=\"div\"]",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -384,7 +384,7 @@
'selector': "[data-attr-whitespace~=\"\\0000e9\"]",
'expect': ["attr-whitespace-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -392,7 +392,7 @@
'selector': "[data-attr-whitespace\_foo~=\"\\e9\"]",
'expect': ["attr-whitespace-div5"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -407,7 +407,7 @@
"attr-whitespace-a7"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -422,7 +422,7 @@
"attr-whitespace-a7"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -437,7 +437,7 @@
"attr-whitespace-a7"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -445,7 +445,7 @@
'selector': "#attr-whitespace a[rel~=\"book mark\"]",
'expect': [] /* no matches */,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -453,7 +453,7 @@
'selector': "#attr-whitespace [title~=中文]",
'expect': ["attr-whitespace-p1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// - hyphen-separated list [att|=val]
@@ -463,7 +463,7 @@
'selector': "#attr-hyphen-div1[lang|=\"en\"]",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -471,7 +471,7 @@
'selector': "#attr-hyphen-div2[lang|=\"fr\"]",
'expect': ["attr-hyphen-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -479,7 +479,7 @@
'selector': "#attr-hyphen-div3[lang|=\"en\"]",
'expect': ["attr-hyphen-div3"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -487,7 +487,7 @@
'selector': "#attr-hyphen-div4[lang|=\"es-AR\"]",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
// - substring begins-with [att^=val] (Level 3)
@@ -497,7 +497,7 @@
'selector': "#attr-begins a[href^=\"http://www\"]",
'expect': ["attr-begins-a1", "attr-begins-a3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -505,7 +505,7 @@
'selector': "#attr-begins [lang^=\"en-\"]",
'expect': ["attr-begins-div2", "attr-begins-div4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -513,7 +513,7 @@
'selector': "#attr-begins [class^=apple]",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
{
'name':
@@ -521,7 +521,7 @@
'selector': "#attr-begins [class^=' apple']",
'expect': ["attr-begins-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -529,7 +529,7 @@
'selector': "#attr-begins [class^=\" apple\"]",
'expect': ["attr-begins-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -537,7 +537,7 @@
'selector': "#attr-begins [class^= apple]",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// - substring ends-with [att\$=val] (Level 3)
@@ -547,7 +547,7 @@
'selector': "#attr-ends a[href\$=\".org\"]",
'expect': ["attr-ends-a1", "attr-ends-a3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -555,7 +555,7 @@
'selector': "#attr-ends [lang\$=\"-CH\"]",
'expect': ["attr-ends-div2", "attr-ends-div4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -563,7 +563,7 @@
'selector': "#attr-ends [class\$=apple]",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
{
'name':
@@ -571,7 +571,7 @@
'selector': "#attr-ends [class\$='apple ']",
'expect': ["attr-ends-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -579,7 +579,7 @@
'selector': "#attr-ends [class\$=\"apple \"]",
'expect': ["attr-ends-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -587,7 +587,7 @@
'selector': "#attr-ends [class\$=apple ]",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// - substring contains [att*=val] (Level 3)
@@ -597,7 +597,7 @@
'selector': "#attr-contains a[href*=\"http://www\"]",
'expect': ["attr-contains-a1", "attr-contains-a3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -605,7 +605,7 @@
'selector': "#attr-contains a[href*=\".org\"]",
'expect': ["attr-contains-a1", "attr-contains-a2"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -613,7 +613,7 @@
'selector': "#attr-contains a[href*=\".example.\"]",
'expect': ["attr-contains-a1", "attr-contains-a3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -621,7 +621,7 @@
'selector': "#attr-contains [lang*=\"en-\"]",
'expect': ["attr-contains-div2", "attr-contains-div6"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -629,7 +629,7 @@
'selector': "#attr-contains [lang*=\"-CH\"]",
'expect': ["attr-contains-div3", "attr-contains-div5"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -637,7 +637,7 @@
'selector': "#attr-contains [class*=' apple']",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -645,7 +645,7 @@
'selector': "#attr-contains [class*='orange ']",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -653,7 +653,7 @@
'selector': "#attr-contains [class*='ple banana ora']",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -661,7 +661,7 @@
'selector': "#attr-contains [class*=\" apple\"]",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -669,7 +669,7 @@
'selector': "#attr-contains [class*=\"orange \"]",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -677,7 +677,7 @@
'selector': "#attr-contains [class*=\"ple banana ora\"]",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -685,7 +685,7 @@
'selector': "#attr-contains [class*= apple]",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -693,7 +693,7 @@
'selector': "#attr-contains [class*=orange ]",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -701,7 +701,7 @@
'selector': "#attr-contains [class*= banana ]",
'expect': ["attr-contains-p1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// Pseudo-classes
@@ -712,7 +712,7 @@
'expect': ["html"],
'exclude': ["element", "fragment", "detached"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': ":root pseudo-class selector, not matching document root element",
@@ -720,7 +720,7 @@
'expect': [] /*no matches*/,
'exclude': ["document"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// - :nth-child(n) (Level 3)
@@ -734,7 +734,7 @@
"pseudo-nth-td15"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': ":nth-child selector, matching every third child element",
@@ -746,7 +746,7 @@
"pseudo-nth-li12"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -760,7 +760,7 @@
"pseudo-nth-li12"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -768,7 +768,7 @@
'selector': "#pseudo-nth-p1 :nth-child(4n-1)",
'expect': ["pseudo-nth-em2", "pseudo-nth-span3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :nth-last-child (Level 3)
@@ -782,7 +782,7 @@
"pseudo-nth-td16"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -795,7 +795,7 @@
"pseudo-nth-li10"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -809,7 +809,7 @@
"pseudo-nth-li9"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -817,7 +817,7 @@
'selector': "#pseudo-nth-p1 :nth-last-child(4n-1)",
'expect': ["pseudo-nth-span2", "pseudo-nth-span4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :nth-of-type(n) (Level 3)
@@ -826,7 +826,7 @@
'selector': "#pseudo-nth-p1 em:nth-of-type(3)",
'expect': ["pseudo-nth-em3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -840,7 +840,7 @@
"pseudo-nth-em4"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -848,7 +848,7 @@
'selector': "#pseudo-nth-p1 span:nth-of-type(2n-1)",
'expect': ["pseudo-nth-span1", "pseudo-nth-span3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :nth-last-of-type(n) (Level 3)
@@ -857,7 +857,7 @@
'selector': "#pseudo-nth-p1 em:nth-last-of-type(3)",
'expect': ["pseudo-nth-em2"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -871,7 +871,7 @@
"pseudo-nth-span3"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -879,7 +879,7 @@
'selector': "#pseudo-nth-p1 span:nth-last-of-type(2n-1)",
'expect': ["pseudo-nth-span2", "pseudo-nth-span4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :first-of-type (Level 3)
@@ -888,7 +888,7 @@
'selector': "#pseudo-nth-p1 em:first-of-type",
'expect': ["pseudo-nth-em1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -896,7 +896,7 @@
'selector': "#pseudo-nth-p1 :first-of-type",
'expect': ["pseudo-nth-span1", "pseudo-nth-em1", "pseudo-nth-strong1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -904,7 +904,7 @@
'selector': "#pseudo-nth-table1 tr :first-of-type",
'expect': ["pseudo-nth-td1", "pseudo-nth-td7", "pseudo-nth-td13"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :last-of-type (Level 3)
@@ -913,7 +913,7 @@
'selector': "#pseudo-nth-p1 em:last-of-type",
'expect': ["pseudo-nth-em4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -921,7 +921,7 @@
'selector': "#pseudo-nth-p1 :last-of-type",
'expect': ["pseudo-nth-span4", "pseudo-nth-strong2", "pseudo-nth-em4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -929,7 +929,7 @@
'selector': "#pseudo-nth-table1 tr :last-of-type",
'expect': ["pseudo-nth-td6", "pseudo-nth-td12", "pseudo-nth-td18"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :first-child
@@ -939,7 +939,7 @@
'selector': "#pseudo-first-child div:first-child",
'expect': ["pseudo-first-child-div1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -948,7 +948,7 @@
".pseudo-first-child-div2:first-child, .pseudo-first-child-div3:first-child",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -960,7 +960,7 @@
"pseudo-first-child-span5"
],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// - :last-child (Level 3)
@@ -970,7 +970,7 @@
'selector': "#pseudo-last-child div:last-child",
'expect': ["pseudo-last-child-div3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -979,7 +979,7 @@
".pseudo-last-child-div1:last-child, .pseudo-last-child-div2:first-child",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
{
'name':
@@ -991,7 +991,7 @@
"pseudo-last-child-span6"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :only-child (Level 3)
@@ -1001,7 +1001,7 @@
'selector': "#pseudo-only :only-child",
'expect': ["pseudo-only-span1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -1009,7 +1009,7 @@
'selector': "#pseudo-only em:only-child",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// - :only-of-type (Level 3)
@@ -1019,7 +1019,7 @@
'selector': "#pseudo-only :only-of-type",
'expect': ["pseudo-only-span1", "pseudo-only-em1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -1027,7 +1027,7 @@
'selector': "#pseudo-only em:only-of-type",
'expect': ["pseudo-only-em1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :empty (Level 3)
@@ -1036,14 +1036,14 @@
'selector': "#pseudo-empty p:empty",
'expect': ["pseudo-empty-p1", "pseudo-empty-p2"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': ":empty pseudo-class selector, matching all empty elements",
'selector': "#pseudo-empty :empty",
'expect': ["pseudo-empty-p1", "pseudo-empty-p2", "pseudo-empty-span1"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :link and :visited
@@ -1055,7 +1055,7 @@
'selector': "#pseudo-link :link, #pseudo-link :visited",
'expect': ["pseudo-link-a1", "pseudo-link-a2", "pseudo-link-area1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1064,7 +1064,7 @@
'expect': ["pseudo-link-link1", "pseudo-link-link2"],
'exclude': ["element", "fragment", "detached"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1073,7 +1073,7 @@
'expect': [] /*no matches*/,
'exclude': ["document"],
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1082,7 +1082,7 @@
'expect': [] /*no matches*/,
'exclude': ["document"],
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
// - :target (Level 3)
@@ -1093,7 +1093,7 @@
'expect': [] /*no matches*/,
'exclude': ["document", "element"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
{
'name':
@@ -1102,7 +1102,7 @@
'expect': ["target"],
'exclude': ["fragment", "detached"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :lang()
@@ -1112,7 +1112,7 @@
'expect': ["pseudo-lang-div1"],
'exclude': ["detached", "fragment"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1121,7 +1121,7 @@
'expect': [] /*no matches*/,
'exclude': ["document", "element"],
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1129,7 +1129,7 @@
'selector': "#pseudo-lang-div2:lang(fr)",
'expect': ["pseudo-lang-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1137,14 +1137,14 @@
'selector': "#pseudo-lang-div3:lang(en)",
'expect': ["pseudo-lang-div3"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': ":lang pseudo-class selector, not matching incorrect language",
'selector': "#pseudo-lang-div4:lang(es-AR)",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
// - :enabled (Level 3)
@@ -1166,7 +1166,7 @@
"pseudo-ui-button1"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :disabled (Level 3)
@@ -1188,7 +1188,7 @@
"pseudo-ui-button2"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :checked (Level 3)
@@ -1203,7 +1203,7 @@
"pseudo-ui-input15"
],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// - :not(s) (Level 3)
@@ -1212,28 +1212,28 @@
'selector': "#not>:not(div)",
'expect': ["not-p1", "not-p2", "not-p3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': ":not pseudo-class selector, matching ",
'selector': "#not * :not(:first-child)",
'expect': ["not-em1", "not-em2", "not-em3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': ":not pseudo-class selector, matching nothing",
'selector': ":not(*)",
'expect': [] /* no matches */,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
{
'name': ":not pseudo-class selector, matching nothing",
'selector': ":not(*|*)",
'expect': [] /* no matches */,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// Pseudo-elements
@@ -1244,7 +1244,7 @@
'selector': "#pseudo-element:first-line",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1252,7 +1252,7 @@
'selector': "#pseudo-element::first-line",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// - ::first-letter
@@ -1262,7 +1262,7 @@
'selector': "#pseudo-element:first-letter",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1270,7 +1270,7 @@
'selector': "#pseudo-element::first-letter",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// - ::before
@@ -1280,7 +1280,7 @@
'selector': "#pseudo-element:before",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1288,7 +1288,7 @@
'selector': "#pseudo-element::before",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// - ::after
@@ -1298,7 +1298,7 @@
'selector': "#pseudo-element:after",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1306,7 +1306,7 @@
'selector': "#pseudo-element::after",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
// Class Selectors
@@ -1315,7 +1315,7 @@
'selector': ".class-p",
'expect': ["class-p1", "class-p2", "class-p3"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1330,14 +1330,14 @@
"class-div4"
],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Class Selector, chained, with type selector",
'selector': "div.apple.banana.orange",
'expect': ["class-div1", "class-div2", "class-div3", "class-div4"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// Caution: If copying and pasting the folowing non-ASCII classes, ensure unicode normalisation is not performed in the process.
{
@@ -1346,7 +1346,7 @@
'selector': ".台北Táiběi",
'expect': ["class-span1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1354,7 +1354,7 @@
'selector': ".台北",
'expect': ["class-span1", "class-span2"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1362,7 +1362,7 @@
'selector': ".台北Táiběi.台北",
'expect': ["class-span1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1370,7 +1370,7 @@
'selector': ".foo\\:bar",
'expect': ["class-span3"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1378,7 +1378,7 @@
'selector': ".test\\.foo\\[5\\]bar",
'expect': ["class-span4"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// ID Selectors
@@ -1387,42 +1387,42 @@
'selector': "#id #id-div1",
'expect': ["id-div1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "ID selector, chained, matching element with specified id",
'selector': "#id-div1, #id-div1",
'expect': ["id-div1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "ID selector, chained, matching element with specified id",
'selector': "#id-div1, #id-div2",
'expect': ["id-div1", "id-div2"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "ID Selector, chained, with type selector",
'selector': "div#id-div1, div#id-div2",
'expect': ["id-div1", "id-div2"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "ID selector, not matching non-existent descendant",
'selector': "#id #none",
'expect': [] /*no matches*/,
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "ID selector, not matching non-existent ancestor",
'selector': "#none #id-div1",
'expect': [] /*no matches*/,
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "ID selector, matching multiple elements with duplicate id",
@@ -1434,7 +1434,7 @@
"id-li-duplicate"
],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// Caution: If copying and pasting the folowing non-ASCII IDs, ensure unicode normalisation is not performed in the process.
@@ -1443,21 +1443,21 @@
'selector': "#台北Táiběi",
'expect': ["台北Táiběi"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "ID selector, matching id value using non-ASCII characters",
'selector': "#台北",
'expect': ["台北"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "ID selector, matching id values using non-ASCII characters",
'selector': "#台北Táiběi, #台北",
'expect': ["台北Táiběi", "台北"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// XXX runMatchesTest() in level2-lib.js can't handle this because obtaining the expected nodes requires escaping characters when generating the selector from 'expect' values
@@ -1466,14 +1466,14 @@
'selector': "#\\#foo\\:bar",
'expect': ["#foo:bar"],
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "ID selector, matching element with id with escaped character",
'selector': "#test\\.foo\\[5\\]bar",
'expect': ["test.foo[5]bar"],
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
// Namespaces
@@ -1488,21 +1488,21 @@
"any-namespace-div4"
],
'level': 3,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "Namespace selector, matching div elements in no namespace only",
'selector': "#no-namespace |div",
'expect': ["no-namespace-div3"],
'level': 3,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "Namespace selector, matching any elements in no namespace only",
'selector': "#no-namespace |*",
'expect': ["no-namespace-div3"],
'level': 3,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
// Combinators
@@ -1518,7 +1518,7 @@
"descendant-div4"
],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1527,7 +1527,7 @@
'expect': ["descendant-div1"],
'exclude': ["detached", "fragment"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1535,7 +1535,7 @@
'selector': "div #descendant-div1",
'expect': ["descendant-div1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1543,7 +1543,7 @@
'selector': "#descendant #descendant-div2",
'expect': ["descendant-div2"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1551,7 +1551,7 @@
'selector': "#descendant .descendant-div2",
'expect': ["descendant-div2"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1559,7 +1559,7 @@
'selector': ".descendant-div1 .descendant-div3",
'expect': ["descendant-div3"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1567,14 +1567,14 @@
'selector': "#descendant-div1 #descendant-div4",
'expect': [] /*no matches*/,
'level': 1,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "Descendant combinator, whitespace characters",
'selector': "#descendant\t\r\n#descendant-div2",
'expect': ["descendant-div2"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// - Child combinator '>'
@@ -1584,7 +1584,7 @@
'selector': "#child>div",
'expect': ["child-div1", "child-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1592,7 +1592,7 @@
'selector': "div>#child-div1",
'expect': ["child-div1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1600,7 +1600,7 @@
'selector': "#child>#child-div1",
'expect': ["child-div1"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1608,7 +1608,7 @@
'selector': "#child-div1>.child-div2",
'expect': ["child-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1616,7 +1616,7 @@
'selector': ".child-div1>.child-div2",
'expect': ["child-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1624,7 +1624,7 @@
'selector': "#child>#child-div3",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1632,7 +1632,7 @@
'selector': "#child-div1>.child-div3",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name':
@@ -1640,35 +1640,35 @@
'selector': ".child-div1>.child-div3",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "Child combinator, surrounded by whitespace",
'selector': "#child-div1\t\r\n>\t\r\n#child-div2",
'expect': ["child-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Child combinator, whitespace after",
'selector': "#child-div1>\t\r\n#child-div2",
'expect': ["child-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Child combinator, whitespace before",
'selector': "#child-div1\t\r\n>#child-div2",
'expect': ["child-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Child combinator, no whitespace",
'selector': "#child-div1>#child-div2",
'expect': ["child-div2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// - Adjacent sibling combinator '+'
@@ -1678,7 +1678,7 @@
'selector': "#adjacent-div2+div",
'expect': ["adjacent-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1686,7 +1686,7 @@
'selector': "div+#adjacent-div4",
'expect': ["adjacent-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1694,7 +1694,7 @@
'selector': "#adjacent-div2+#adjacent-div4",
'expect': ["adjacent-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1702,7 +1702,7 @@
'selector': "#adjacent-div2+.adjacent-div4",
'expect': ["adjacent-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1710,7 +1710,7 @@
'selector': ".adjacent-div2+.adjacent-div4",
'expect': ["adjacent-div4"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1718,7 +1718,7 @@
'selector': "#adjacent div+p",
'expect': ["adjacent-p2"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name':
@@ -1726,35 +1726,35 @@
'selector': "#adjacent-div2+#adjacent-p2, #adjacent-div2+#adjacent-div1",
'expect': [] /*no matches*/,
'level': 2,
- 'testType': TEST_QSA_BASELINE
+ 'testType': testQsaBaseline
},
{
'name': "Adjacent sibling combinator, surrounded by whitespace",
'selector': "#adjacent-p2\t\r\n+\t\r\n#adjacent-p3",
'expect': ["adjacent-p3"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Adjacent sibling combinator, whitespace after",
'selector': "#adjacent-p2+\t\r\n#adjacent-p3",
'expect': ["adjacent-p3"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Adjacent sibling combinator, whitespace before",
'selector': "#adjacent-p2\t\r\n+#adjacent-p3",
'expect': ["adjacent-p3"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Adjacent sibling combinator, no whitespace",
'selector': "#adjacent-p2+#adjacent-p3",
'expect': ["adjacent-p3"],
'level': 2,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
// - General sibling combinator ~ (Level 3)
@@ -1764,7 +1764,7 @@
'selector': "#sibling-div2~div",
'expect': ["sibling-div4", "sibling-div6"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -1772,7 +1772,7 @@
'selector': "div~#sibling-div4",
'expect': ["sibling-div4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -1780,7 +1780,7 @@
'selector': "#sibling-div2~#sibling-div4",
'expect': ["sibling-div4"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -1788,7 +1788,7 @@
'selector': "#sibling-div2~.sibling-div",
'expect': ["sibling-div4", "sibling-div6"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -1796,7 +1796,7 @@
'selector': "#sibling div~p",
'expect': ["sibling-p2", "sibling-p3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name':
@@ -1804,7 +1804,7 @@
'selector': "#sibling>p~div",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
{
'name':
@@ -1812,35 +1812,35 @@
'selector': "#sibling-div2~#sibling-div3, #sibling-div2~#sibling-div1",
'expect': [] /*no matches*/,
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL
+ 'testType': testQsaAdditional
},
{
'name': "General sibling combinator, surrounded by whitespace",
'selector': "#sibling-p2\t\r\n~\t\r\n#sibling-p3",
'expect': ["sibling-p3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': "General sibling combinator, whitespace after",
'selector': "#sibling-p2~\t\r\n#sibling-p3",
'expect': ["sibling-p3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': "General sibling combinator, whitespace before",
'selector': "#sibling-p2\t\r\n~#sibling-p3",
'expect': ["sibling-p3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
{
'name': "General sibling combinator, no whitespace",
'selector': "#sibling-p2~#sibling-p3",
'expect': ["sibling-p3"],
'level': 3,
- 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
+ 'testType': testQsaAdditional | testMatchBaseline
},
// Group of selectors (comma)
@@ -1849,27 +1849,27 @@
'selector': "#group em\t\r \n,\t\r \n#group strong",
'expect': ["group-em1", "group-strong1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Syntax, group of selectors separator, whitespace after",
'selector': "#group em,\t\r\n#group strong",
'expect': ["group-em1", "group-strong1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Syntax, group of selectors separator, whitespace before",
'selector': "#group em\t\r\n,#group strong",
'expect': ["group-em1", "group-strong1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
{
'name': "Syntax, group of selectors separator, no whitespace",
'selector': "#group em,#group strong",
'expect': ["group-em1", "group-strong1"],
'level': 1,
- 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE
+ 'testType': testQsaBaseline | testMatchBaseline
},
];
diff --git a/test/support.dart b/test/support.dart
index 022da35..0e7358c 100644
--- a/test/support.dart
+++ b/test/support.dart
@@ -15,7 +15,7 @@
Map<String, TreeBuilderFactory> get treeTypes {
if (_treeTypes == null) {
// TODO(jmesserly): add DOM here once it's implemented
- _treeTypes = {"simpletree": (useNs) => new TreeBuilder(useNs)};
+ _treeTypes = {"simpletree": (useNs) => TreeBuilder(useNs)};
}
return _treeTypes;
}
@@ -25,7 +25,7 @@
final testDataDir = p.join(testDir, 'data');
Iterable<String> getDataFiles(String subdirectory) {
- var dir = new Directory(p.join(testDataDir, subdirectory));
+ var dir = Directory(p.join(testDataDir, subdirectory));
return dir.listSync().where((f) => f is File).map((f) => f.path);
}
@@ -37,7 +37,7 @@
TestData(String filename, [this.newTestHeading = "data"])
// Note: can't use readAsLinesSync here because it splits on \r
- : _text = new File(filename).readAsStringSync();
+ : _text = File(filename).readAsStringSync();
// Note: in Python this was a generator, but since we can't do that in Dart,
// it's easier to convert it into an upfront computation.
@@ -93,7 +93,7 @@
/// Serialize the [document] into the html5 test data format.
testSerializer(document) {
- return (new TestSerializer()..visit(document)).toString();
+ return (TestSerializer()..visit(document)).toString();
}
/// Serializes the DOM into test format. See [testSerializer].
@@ -102,7 +102,7 @@
int _indent = 0;
String _spaces = '';
- TestSerializer() : _str = new StringBuffer();
+ TestSerializer() : _str = StringBuffer();
String toString() => _str.toString();
@@ -111,11 +111,11 @@
set indent(int value) {
if (_indent == value) return;
- var arr = new List<int>(value);
+ var arr = List<int>(value);
for (int i = 0; i < value; i++) {
arr[i] = 32;
}
- _spaces = new String.fromCharCodes(arr);
+ _spaces = String.fromCharCodes(arr);
_indent = value;
}
@@ -152,7 +152,7 @@
_str.write(node);
if (node.attributes.isNotEmpty) {
indent += 2;
- var keys = new List.from(node.attributes.keys);
+ var keys = List.from(node.attributes.keys);
keys.sort((x, y) => x.compareTo(y));
for (var key in keys) {
var v = node.attributes[key];
diff --git a/test/tokenizer_test.dart b/test/tokenizer_test.dart
index 7432cda..744a496 100644
--- a/test/tokenizer_test.dart
+++ b/test/tokenizer_test.dart
@@ -25,16 +25,16 @@
List parse(String str) {
// Note: we need to pass bytes to the tokenizer if we want it to handle BOM.
var bytes = codepointsToUtf8(toCodepoints(str));
- var tokenizer = new HtmlTokenizer(bytes, encoding: 'utf-8');
+ var tokenizer = HtmlTokenizer(bytes, encoding: 'utf-8');
outputTokens = [];
// Note: we can't get a closure of the state method. However, we can
// create a new closure to invoke it via mirrors.
var mtok = reflect(tokenizer);
- tokenizer.state = () => mtok.invoke(new Symbol(_state), const []).reflectee;
+ tokenizer.state = () => mtok.invoke(Symbol(_state), const []).reflectee;
if (_lastStartTag != null) {
- tokenizer.currentToken = new StartTagToken(_lastStartTag);
+ tokenizer.currentToken = StartTagToken(_lastStartTag);
}
while (tokenizer.moveNext()) {
@@ -182,8 +182,8 @@
if (!testInfo.containsKey('lastStartTag')) {
testInfo['lastStartTag'] = null;
}
- var parser = new TokenizerTestParser(
- testInfo['initialState'], testInfo['lastStartTag']);
+ var parser =
+ TokenizerTestParser(testInfo['initialState'], testInfo['lastStartTag']);
var tokens = parser.parse(testInfo['input']);
tokens = concatenateCharacterTokens(tokens);
var received = normalizeTokens(tokens);
@@ -230,8 +230,8 @@
String camelCase(String s) {
s = s.toLowerCase();
- var result = new StringBuffer();
- for (var match in new RegExp(r"\W+(\w)(\w+)").allMatches(s)) {
+ var result = StringBuffer();
+ for (var match in RegExp(r"\W+(\w)(\w+)").allMatches(s)) {
if (result.length == 0) result.write(s.substring(0, match.start));
result.write(match.group(1).toUpperCase());
result.write(match.group(2));
@@ -243,7 +243,7 @@
for (var path in getDataFiles('tokenizer')) {
if (!path.endsWith('.test')) continue;
- var text = new File(path).readAsStringSync();
+ var text = File(path).readAsStringSync();
var tests = jsonDecode(text);
var testName = pathos.basenameWithoutExtension(path);
var testList = tests['tests'];