From 69e72a5030b7a1939d92d02fbd79a8c6e2aff10a Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 29 Sep 2022 09:25:00 -0700 Subject: [PATCH 01/33] Use growable lists and avoid dynamic --- analysis_options.yaml | 4 ++-- lib/dom.dart | 5 +++-- lib/dom_parsing.dart | 2 +- lib/parser.dart | 8 ++++---- lib/src/encoding_parser.dart | 4 ++-- lib/src/tokenizer.dart | 7 ++++--- lib/src/treebuilder.dart | 2 +- test/tokenizer_test.dart | 6 +++--- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index c181e0a..2408490 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,7 +1,7 @@ include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-casts: false + language: + strict-casts: true errors: # https://github.com/dart-lang/linter/issues/1649 prefer_collection_literals: ignore diff --git a/lib/dom.dart b/lib/dom.dart index 6da9220..5ffc15f 100644 --- a/lib/dom.dart +++ b/lib/dom.dart @@ -885,7 +885,8 @@ class FilteredElementList extends IterableBase // // TODO(nweiz): we don't always need to create a new list. For example // forEach, every, any, ... could directly work on the _childNodes. - List get _filtered => _childNodes.whereType().toList(); + List get _filtered => + _childNodes.whereType().toList(growable: false); @override void forEach(void Function(Element) action) { @@ -1028,7 +1029,7 @@ class FilteredElementList extends IterableBase @override List toList({bool growable = true}) => - List.from(this, growable: growable); + List.of(this, growable: growable); @override Set toSet() => Set.from(this); diff --git a/lib/dom_parsing.dart b/lib/dom_parsing.dart index 973931b..35c8dc7 100644 --- a/lib/dom_parsing.dart +++ b/lib/dom_parsing.dart @@ -32,7 +32,7 @@ class TreeVisitor { void visitChildren(Node node) { // Allow for mutations (remove works) while iterating. - for (var child in node.nodes.toList()) { + for (var child in node.nodes.toList(growable: false)) { visit(child); } } diff --git a/lib/parser.dart b/lib/parser.dart index 332370c..30c34b3 100644 --- a/lib/parser.dart +++ b/lib/parser.dart @@ -331,7 +331,7 @@ class HtmlParser { // When the loop finishes it's EOF var reprocess = true; - final reprocessPhases = []; + final reprocessPhases = []; while (reprocess) { reprocessPhases.add(phase); reprocess = phase.processEOF(); @@ -430,7 +430,7 @@ class HtmlParser { 'ychannelselector': 'yChannelSelector', 'zoomandpan': 'zoomAndPan' }; - for (var originalName in token.data.keys.toList()) { + for (var originalName in token.data.keys.toList(growable: false)) { final svgName = replacements[originalName as String]; if (svgName != null) { token.data[svgName] = token.data.remove(originalName)!; @@ -456,7 +456,7 @@ class HtmlParser { 'xmlns:xlink': AttributeName('xmlns', 'xlink', Namespaces.xmlns) }; - for (var originalName in token.data.keys.toList()) { + for (var originalName in token.data.keys.toList(growable: false)) { final foreignName = replacements[originalName as String]; if (foreignName != null) { token.data[foreignName] = token.data.remove(originalName)!; @@ -1468,7 +1468,7 @@ class InBodyPhase extends Phase { tree.insertElement(token); final element = tree.openElements.last; - final matchingElements = []; + final matchingElements = []; for (Node? node in tree.activeFormattingElements.reversed) { if (node == null) { break; diff --git a/lib/src/encoding_parser.dart b/lib/src/encoding_parser.dart index e417351..defe57e 100644 --- a/lib/src/encoding_parser.dart +++ b/lib/src/encoding_parser.dart @@ -247,8 +247,8 @@ class EncodingParser { return null; } // Step 3 - final attrName = []; - final attrValue = []; + final attrName = []; + final attrValue = []; // Step 4 attribute name while (true) { if (c == null) { diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart index 3defd4e..603d405 100644 --- a/lib/src/tokenizer.dart +++ b/lib/src/tokenizer.dart @@ -174,7 +174,7 @@ class HtmlTokenizer implements Iterator { radix = 16; } - final charStack = []; + final charStack = []; // Consume all the characters that are in range while making sure we // don't hit an EOF. @@ -297,8 +297,9 @@ class HtmlTokenizer implements Iterator { while (charStack.last != eof) { final name = charStack.join(); - filteredEntityList = - filteredEntityList.where((e) => e.startsWith(name)).toList(); + filteredEntityList = filteredEntityList + .where((e) => e.startsWith(name)) + .toList(growable: false); if (filteredEntityList.isEmpty) { break; diff --git a/lib/src/treebuilder.dart b/lib/src/treebuilder.dart index bc4c089..d477eb0 100644 --- a/lib/src/treebuilder.dart +++ b/lib/src/treebuilder.dart @@ -111,7 +111,7 @@ class TreeBuilder { final exactNode = target is Node; var listElements1 = scopingElements; - var listElements2 = const []; + var listElements2 = const []; var invert = false; if (variant != null) { switch (variant) { diff --git a/test/tokenizer_test.dart b/test/tokenizer_test.dart index e197b94..e0af7fb 100644 --- a/test/tokenizer_test.dart +++ b/test/tokenizer_test.dart @@ -232,13 +232,13 @@ Map unescape(Map testInfo) { dynamic decode(inp) => inp == '\u0000' ? inp : jsonDecode('"$inp"'); testInfo['input'] = decode(testInfo['input']); - for (var token in testInfo['output']) { + for (var token in testInfo['output'] as List) { if (token == 'ParseError') { continue; } else { token[1] = decode(token[1]); if ((token as List).length > 2) { - for (var pair in token[2]) { + for (var pair in token[2] as List) { final key = pair[0]; final value = pair[1]; token[2].remove(key); @@ -276,7 +276,7 @@ void main() async { final testInfo = testList[index] as Map; testInfo.putIfAbsent('initialStates', () => ['Data state']); - for (var initialState in testInfo['initialStates']) { + for (var initialState in testInfo['initialStates'] as List) { test(testInfo['description'], () { testInfo['initialState'] = camelCase(initialState as String); runTokenizerTest(testInfo); From 4185afdd0108358d3bd3a867d763909fd6c2c841 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 29 Sep 2022 18:02:10 +0000 Subject: [PATCH 02/33] add markdown badges to the readme --- README.md | 21 ++++++++++++++------- pubspec.yaml | 1 - 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bd60674..fafae1b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -This is a pure Dart HTML5 parser. -It's a port of [html5lib](https://github.com/html5lib/html5lib-python) from -Python. +[![Dart CI](https://github.com/dart-lang/html/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/html/actions/workflows/test-package.yml) +[![pub package](https://img.shields.io/pub/v/html.svg)](https://pub.dev/packages/html) +[![package publisher](https://img.shields.io/pub/publisher/html.svg)](https://pub.dev/packages/html/publisher) -# Usage +This is a Dart HTML5 parser. + +## Usage Parsing HTML is easy! @@ -16,6 +18,11 @@ main() { } ``` -You can pass a String or list of bytes to `parse`. -There's also `parseFragment` for parsing a document fragment, and `HtmlParser` -if you want more low level control. +You can pass a String or list of bytes to `parse`. There's also `parseFragment` +for parsing a document fragment, and `HtmlParser` if you want more low level +control. + +## Background + +This package was a port of the Python +[html5lib](https://github.com/html5lib/html5lib-python) library. diff --git a/pubspec.yaml b/pubspec.yaml index 734c33e..7cd1d85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,5 @@ name: html version: 0.15.1-dev - description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/html From 5a0be754fbc1b02aad82eb452d7aefc680d3691a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 29 Sep 2022 18:08:28 +0000 Subject: [PATCH 03/33] update to our current CI best practices --- .github/dependabot.yml | 15 ++++++--------- .github/workflows/test-package.yml | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 430a85e..2144819 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,8 @@ -# Set update schedule for GitHub Actions -# See https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot - +# Dependabot configuration file. version: 2 -updates: -- package-ecosystem: "github-actions" - directory: "/" - schedule: - # Check for updates to GitHub Actions every weekday - interval: "daily" +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 2e8f5d4..c197eec 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,8 +14,8 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1 + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: dev - id: install From 07a1f46ed24b584f1c40a85e13dc08aeccd601fe Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 29 Sep 2022 13:38:53 -0700 Subject: [PATCH 04/33] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6adaec5..340f7d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ - Move `htmlSerializeEscape` to its own library, `package:html/html_escape.dart`, which is exported from `package:html/dom_parsing.dart`. +- Use more non-growable lists, and type annotations on List literals. +- Switch analysis option `implicit-casts: false` to `strict-casts: true`. ## 0.15.0 From 0bf601959ac98e6cdf1925a1cdab70bd6a5ddc45 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 19 Oct 2022 19:45:35 +0000 Subject: [PATCH 05/33] rev the package version in preparation for publishing (#190) --- CHANGELOG.md | 2 +- README.md | 2 +- analysis_options.yaml | 2 ++ pubspec.yaml | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 340f7d7..ae8d726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.15.1-dev +## 0.15.1 - Move `htmlSerializeEscape` to its own library, `package:html/html_escape.dart`, which is exported from diff --git a/README.md b/README.md index fafae1b..f5388b2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![pub package](https://img.shields.io/pub/v/html.svg)](https://pub.dev/packages/html) [![package publisher](https://img.shields.io/pub/publisher/html.svg)](https://pub.dev/packages/html/publisher) -This is a Dart HTML5 parser. +A Dart implementation of an HTML5 parser. ## Usage diff --git a/analysis_options.yaml b/analysis_options.yaml index 2408490..5f87ffe 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,10 +1,12 @@ include: package:lints/recommended.yaml + analyzer: language: strict-casts: true errors: # https://github.com/dart-lang/linter/issues/1649 prefer_collection_literals: ignore + linter: rules: - avoid_dynamic_calls diff --git a/pubspec.yaml b/pubspec.yaml index 7cd1d85..7b9527c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: html -version: 0.15.1-dev +version: 0.15.1 description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/html From 28fb8b97acf471bedcfa4eaf38899a0f65d5e30d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 9 Nov 2022 15:34:41 -0800 Subject: [PATCH 06/33] blast_repo fixes (#191) Dependabot GitHub Action --- .github/dependabot.yml | 1 + .github/workflows/test-package.yml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2144819..1603cdd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,5 @@ # Dependabot configuration file. +# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates version: 2 updates: diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index c197eec..d0d4ea0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: dev @@ -34,8 +34,8 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install From 3dd00b0ca99e222697e6b6dc653774dc877da420 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 10:12:19 -0800 Subject: [PATCH 07/33] Bump actions/checkout from 3.1.0 to 3.2.0 (#193) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8...755da8c3cf115ac066823e79a1e1788f8940201b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index d0d4ea0..990dd45 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From a5be27f24c30e39c19f853850cba333b885c0aec Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 27 Jan 2023 07:56:40 -0800 Subject: [PATCH 08/33] finish work for avoid_dynamic_calls (#196) --- .github/workflows/test-package.yml | 2 +- CHANGELOG.md | 5 + analysis_options.yaml | 7 +- lib/parser.dart | 15 ++- lib/src/constants.dart | 2 +- lib/src/html_input_stream.dart | 4 +- lib/src/list_proxy.dart | 2 +- lib/src/query_selector.dart | 9 +- lib/src/token.dart | 3 +- lib/src/tokenizer.dart | 4 +- lib/src/treebuilder.dart | 14 +- lib/src/utils.dart | 2 +- pubspec.yaml | 6 +- test/parser_test.dart | 2 +- test/selectors/level1_baseline_test.dart | 39 +++--- test/selectors/level1_lib.dart | 155 +++++++++++++++-------- test/selectors/selectors.dart | 104 +++++++-------- test/support.dart | 4 +- test/tokenizer_test.dart | 121 +++++++++--------- 19 files changed, 285 insertions(+), 215 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 990dd45..8421e30 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -32,7 +32,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [2.12.0, dev] + sdk: [2.17.0, dev] steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d diff --git a/CHANGELOG.md b/CHANGELOG.md index ae8d726..0adcd1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.15.2-dev + +- Add additional types at the API boundary (in `lib/parser.dart` and others). +- Update to `package:lints` 2.0. + ## 0.15.1 - Move `htmlSerializeEscape` to its own library, diff --git a/analysis_options.yaml b/analysis_options.yaml index 5f87ffe..715ea40 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -3,12 +3,14 @@ include: package:lints/recommended.yaml analyzer: language: strict-casts: true + strict-raw-types: true errors: # https://github.com/dart-lang/linter/issues/1649 prefer_collection_literals: ignore linter: rules: + - always_declare_return_types - avoid_dynamic_calls - avoid_function_literals_in_foreach_calls - avoid_returning_null @@ -17,14 +19,12 @@ linter: - camel_case_types - cancel_subscriptions - comment_references - # See https://github.com/dart-lang/logging/issues/43 - #- constant_identifier_names + - constant_identifier_names - control_flow_in_finally - directives_ordering - empty_statements - hash_and_equals - implementation_imports - #- invariant_booleans - iterable_contains_unrelated_type - list_remove_unrelated_type - no_adjacent_strings_in_list @@ -41,6 +41,7 @@ linter: - prefer_typing_uninitialized_variables - test_types_in_equals - throw_in_finally + - type_annotate_public_apis - unnecessary_brace_in_string_interps - unnecessary_getters_setters - unnecessary_lambdas diff --git a/lib/parser.dart b/lib/parser.dart index 30c34b3..c4bd1ed 100644 --- a/lib/parser.dart +++ b/lib/parser.dart @@ -15,6 +15,7 @@ library parser; import 'dart:collection'; import 'dart:math'; + import 'package:source_span/source_span.dart'; import 'dom.dart'; @@ -36,7 +37,7 @@ import 'src/utils.dart'; /// [Node.sourceSpan] property will be `null`. When using [generateSpans] you /// can additionally pass [sourceUrl] to indicate where the [input] was /// extracted from. -Document parse(input, +Document parse(dynamic input, {String? encoding, bool generateSpans = false, String? sourceUrl}) { final p = HtmlParser(input, encoding: encoding, generateSpans: generateSpans, sourceUrl: sourceUrl); @@ -55,7 +56,7 @@ Document parse(input, /// [Node.sourceSpan] property will be `null`. When using [generateSpans] you can /// additionally pass [sourceUrl] to indicate where the [input] was extracted /// from. -DocumentFragment parseFragment(input, +DocumentFragment parseFragment(dynamic input, {String container = 'div', String? encoding, bool generateSpans = false, @@ -93,7 +94,7 @@ class HtmlParser { Phase? originalPhase; - var framesetOK = true; + bool framesetOK = true; // These fields hold the different phase singletons. At any given time one // of them will be active. @@ -140,7 +141,7 @@ class HtmlParser { /// automatic conversion of element and attribute names to lower case. Note /// that standard way to parse HTML is to lowercase, which is what the browser /// DOM will do if you request `Element.outerHTML`, for example. - HtmlParser(input, + HtmlParser(dynamic input, {String? encoding, bool parseMeta = true, bool lowercaseElementName = true, @@ -348,7 +349,7 @@ class HtmlParser { .pointSpan(); void parseError(SourceSpan? span, String errorcode, - [Map? datavars = const {}]) { + [Map? datavars = const {}]) { if (!generateSpans && span == null) { span = _lastSpan; } @@ -3943,7 +3944,7 @@ class ParseError implements SourceSpanException { final String errorCode; @override final SourceSpan? span; - final Map? data; + final Map? data; ParseError(this.errorCode, this.span, this.data); @@ -3959,7 +3960,7 @@ class ParseError implements SourceSpanException { String get message => formatStr(errorMessages[errorCode]!, data); @override - String toString({color}) { + String toString({dynamic color}) { final res = span!.message(message, color: color); return span!.sourceUrl == null ? 'ParserError on $res' : 'On $res'; } diff --git a/lib/src/constants.dart b/lib/src/constants.dart index e32e037..152f85b 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -265,7 +265,7 @@ class Namespaces { } } -const List scopingElements = [ +const List> scopingElements = [ Pair(Namespaces.html, 'applet'), Pair(Namespaces.html, 'caption'), Pair(Namespaces.html, 'html'), diff --git a/lib/src/html_input_stream.dart b/lib/src/html_input_stream.dart index a0e490f..54e0231 100644 --- a/lib/src/html_input_stream.dart +++ b/lib/src/html_input_stream.dart @@ -35,7 +35,7 @@ class HtmlInputStream { /// Raw UTF-16 codes, used if a Dart String is passed in. List? _rawChars; - var errors = Queue(); + Queue errors = Queue(); SourceFile? fileInfo; @@ -57,7 +57,7 @@ class HtmlInputStream { /// element) /// /// [parseMeta] - Look for a element containing encoding information - HtmlInputStream(source, + HtmlInputStream(dynamic source, [String? encoding, bool parseMeta = true, this.generateSpans = false, diff --git a/lib/src/list_proxy.dart b/lib/src/list_proxy.dart index 05086fa..7fe5e82 100644 --- a/lib/src/list_proxy.dart +++ b/lib/src/list_proxy.dart @@ -22,7 +22,7 @@ abstract class ListProxy extends ListBase { E operator [](int index) => _list[index]; @override - operator []=(int index, E value) { + void operator []=(int index, E value) { _list[index] = value; } diff --git a/lib/src/query_selector.dart b/lib/src/query_selector.dart index b596745..32e0a37 100644 --- a/lib/src/query_selector.dart +++ b/lib/src/query_selector.dart @@ -1,9 +1,8 @@ /// Query selector implementation for our DOM. library html.src.query; -import 'package:csslib/parser.dart' as css; -import 'package:csslib/parser.dart' show TokenKind, Message; -import 'package:csslib/visitor.dart'; // the CSSOM +import 'package:csslib/parser.dart'; +import 'package:csslib/visitor.dart'; import 'package:html/dom.dart'; import 'package:html/src/constants.dart' show isWhitespaceCC; @@ -23,7 +22,7 @@ List querySelectorAll(Node node, String selector) { // http://dev.w3.org/csswg/selectors-4/#grouping SelectorGroup _parseSelectorList(String selector) { final errors = []; - final group = css.parseSelectorGroup(selector, errors: errors); + final group = parseSelectorGroup(selector, errors: errors); if (group == null || errors.isNotEmpty) { throw FormatException("'$selector' is not a valid selector: $errors"); } @@ -127,7 +126,7 @@ class SelectorEvaluator extends Visitor { UnimplementedError("'$selector' selector of type " '${selector.runtimeType} is not implemented'); - FormatException _unsupported(selector) => + FormatException _unsupported(TreeNode selector) => FormatException("'$selector' is not a valid selector"); @override diff --git a/lib/src/token.dart b/lib/src/token.dart index b2c3f40..7a4e743 100644 --- a/lib/src/token.dart +++ b/lib/src/token.dart @@ -2,6 +2,7 @@ library token; import 'dart:collection'; + import 'package:source_span/source_span.dart'; /// An html5 token. @@ -74,7 +75,7 @@ abstract class StringToken extends Token { class ParseErrorToken extends StringToken { /// Extra information that goes along with the error message. - Map? messageParams; + Map? messageParams; ParseErrorToken(String data, {this.messageParams}) : super(data); diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart index 603d405..1ab72a9 100644 --- a/lib/src/tokenizer.dart +++ b/lib/src/tokenizer.dart @@ -1,7 +1,9 @@ library tokenizer; import 'dart:collection'; + import 'package:html/parser.dart' show HtmlParser; + import 'constants.dart'; import 'html_input_stream.dart'; import 'token.dart'; @@ -63,7 +65,7 @@ class HtmlTokenizer implements Iterator { List? _attributes; Set? _attributeNames; - HtmlTokenizer(doc, + HtmlTokenizer(dynamic doc, {String? encoding, bool parseMeta = true, this.lowercaseElementName = true, diff --git a/lib/src/treebuilder.dart b/lib/src/treebuilder.dart index d477eb0..3e39700 100644 --- a/lib/src/treebuilder.dart +++ b/lib/src/treebuilder.dart @@ -2,9 +2,11 @@ library treebuilder; import 'dart:collection'; + import 'package:html/dom.dart'; import 'package:html/parser.dart' show getElementNameTuple; import 'package:source_span/source_span.dart'; + import 'constants.dart'; import 'list_proxy.dart'; import 'token.dart'; @@ -47,7 +49,7 @@ class ActiveFormattingElements extends ListProxy { } // TODO(jmesserly): this should exist in corelib... -bool _mapEquals(Map a, Map b) { +bool _mapEquals(Map a, Map b) { if (a.length != b.length) return false; if (a.isEmpty) return true; @@ -85,7 +87,7 @@ class TreeBuilder { /// Switch the function used to insert an element from the /// normal one to the misnested table one and back again - var insertFromTable = false; + bool insertFromTable = false; TreeBuilder(bool namespaceHTMLElements) : defaultNamespace = namespaceHTMLElements ? Namespaces.html : null { @@ -105,13 +107,13 @@ class TreeBuilder { document = Document(); } - bool elementInScope(target, {String? variant}) { - //If we pass a node in we match that. if we pass a string - //match any node with that name + bool elementInScope(dynamic target, {String? variant}) { + // If we pass a node in we match that. If we pass a string match any node + // with that name. final exactNode = target is Node; var listElements1 = scopingElements; - var listElements2 = const []; + var listElements2 = const >[]; var invert = false; if (variant != null) { switch (variant) { diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 001c706..5c4e359 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -51,7 +51,7 @@ String padWithZeros(String str, int size) { /// Format a string like Python's % string format operator. Right now this only /// supports a [data] dictionary used with %s or %08x. Those were the only /// things needed for [errorMessages]. -String formatStr(String format, Map? data) { +String formatStr(String format, Map? data) { if (data == null) return format; data.forEach((key, value) { final result = StringBuffer(); diff --git a/pubspec.yaml b/pubspec.yaml index 7b9527c..831bce0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,16 +1,16 @@ name: html -version: 0.15.1 +version: 0.15.2-dev description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/html environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.17.0 <3.0.0' dependencies: csslib: ^0.17.0 source_span: ^1.8.0 dev_dependencies: - lints: ^1.0.0 + lints: ^2.0.0 path: ^1.8.0 test: ^1.16.0 diff --git a/test/parser_test.dart b/test/parser_test.dart index 06fb4c6..7f717fa 100644 --- a/test/parser_test.dart +++ b/test/parser_test.dart @@ -35,7 +35,7 @@ void runParserTest( String? innerHTML, String? input, String? expected, - List? errors, + List? errors, TreeBuilderFactory treeCtor, bool namespaceHTMLElements) { // XXX - move this out into the setup function diff --git a/test/selectors/level1_baseline_test.dart b/test/selectors/level1_baseline_test.dart index dd0c2c6..b07d1dc 100644 --- a/test/selectors/level1_baseline_test.dart +++ b/test/selectors/level1_baseline_test.dart @@ -8,6 +8,7 @@ library html.test.selectors.level1_baseline_test; import 'dart:io'; + import 'package:html/dom.dart'; import 'package:html/parser.dart'; import 'package:path/path.dart' as p; @@ -23,8 +24,8 @@ Future testContentDocument() async { return parse(File(testPath).readAsStringSync()); } -var testType = testQsaBaseline; // Only run baseline tests. -var docType = 'html'; // Only run tests suitable for HTML +int testType = testQsaBaseline; // Only run baseline tests. +String docType = 'html'; // Only run tests suitable for HTML void main() async { /* @@ -88,15 +89,17 @@ void main() async { fragment.append(element.clone(true)); // Setup Tests - runSpecialSelectorTests('Document', doc); - runSpecialSelectorTests('Detached Element', detached); - runSpecialSelectorTests('Fragment', fragment); - runSpecialSelectorTests('In-document Element', element); - - verifyStaticList('Document', doc); - verifyStaticList('Detached Element', detached); - verifyStaticList('Fragment', fragment); - verifyStaticList('In-document Element', element); + runSpecialSelectorTests('Document', SelectorAdaptor.document(doc)); + runSpecialSelectorTests( + 'Detached Element', SelectorAdaptor.element(detached)); + runSpecialSelectorTests('Fragment', SelectorAdaptor.fragment(fragment)); + runSpecialSelectorTests( + 'In-document Element', SelectorAdaptor.element(element)); + + verifyStaticList('Document', SelectorAdaptor.document(doc)); + verifyStaticList('Detached Element', SelectorAdaptor.element(detached)); + verifyStaticList('Fragment', SelectorAdaptor.fragment(fragment)); + verifyStaticList('In-document Element', SelectorAdaptor.element(element)); // TODO(jmesserly): fix negative tests //runInvalidSelectorTest('Document', doc, invalidSelectors); @@ -104,10 +107,12 @@ void main() async { //runInvalidSelectorTest('Fragment', fragment, invalidSelectors); //runInvalidSelectorTest('In-document Element', element, invalidSelectors); - runValidSelectorTest('Document', doc, validSelectors, testType, docType); - runValidSelectorTest( - 'Detached Element', detached, validSelectors, testType, docType); - runValidSelectorTest('Fragment', fragment, validSelectors, testType, docType); + runValidSelectorTest('Document', SelectorAdaptor.document(doc), + validSelectors, testType, docType); + runValidSelectorTest('Detached Element', SelectorAdaptor.element(detached), + validSelectors, testType, docType); + runValidSelectorTest('Fragment', SelectorAdaptor.fragment(fragment), + validSelectors, testType, docType); group('out of scope', () { setUp(() { @@ -115,7 +120,7 @@ void main() async { // None of these elements should match }); tearDown(outOfScope.remove); - runValidSelectorTest( - 'In-document Element', element, validSelectors, testType, docType); + runValidSelectorTest('In-document Element', + SelectorAdaptor.element(element), validSelectors, testType, docType); }); } diff --git a/test/selectors/level1_lib.dart b/test/selectors/level1_lib.dart index 6ab3f02..2f62103 100644 --- a/test/selectors/level1_lib.dart +++ b/test/selectors/level1_lib.dart @@ -9,18 +9,14 @@ /// from upstream. library html.test.selectors.level1_lib; -// TODO(https://github.com/dart-lang/html/issues/173): Remove. -// ignore_for_file: avoid_dynamic_calls - import 'package:html/dom.dart'; import 'package:test/test.dart' as unittest; late Document doc; -/* - * Create and append special elements that cannot be created correctly with HTML markup alone. - */ -void setupSpecialElements(parent) { +// Create and append special elements that cannot be created correctly with HTML +// markup alone. +void setupSpecialElements(Element parent) { // Setup null and undefined tests parent.append(doc.createElement('null')); parent.append(doc.createElement('undefined')); @@ -69,38 +65,35 @@ void setupSpecialElements(parent) { parent.append(noNS); } -/* - * Verify that the NodeList returned by querySelectorAll is static and and that a new list is created after - * each call. A static list should not be affected by subsequent changes to the DOM. - */ -void verifyStaticList(String type, dynamic root) { - List pre; - List post; +/// Verify that the NodeList returned by querySelectorAll is static and and that +/// a new list is created after each call. A static list should not be affected +/// by subsequent changes to the DOM. +void verifyStaticList(String type, SelectorAdaptor root) { + List pre; + List post; late int preLength; runTest(() { - pre = root.querySelectorAll('div') as List; + pre = root.querySelectorAll('div'); preLength = pre.length; final div = doc.createElement('div'); - (root is Document ? root.body : root).append(div); + root.isDocument ? root.body!.append(div) : root.append(div); assertEquals( pre.length, preLength, 'The length of the NodeList should not change.'); }, '$type: static NodeList'); runTest(() { - post = root.querySelectorAll('div') as List; + post = root.querySelectorAll('div'); assertEquals(post.length, preLength + 1, 'The length of the new NodeList should be 1 more than the previous list.'); }, '$type: new NodeList'); } -/* - * Verify handling of special values for the selector parameter, including stringification of - * null and undefined, and the handling of the empty string. - */ -void runSpecialSelectorTests(String type, root) { +/// Verify handling of special values for the selector parameter, including +/// stringification of null and undefined, and the handling of the empty string. +void runSpecialSelectorTests(String type, SelectorAdaptor root) { // Dart note: changed these tests because we don't have auto conversion to // String like JavaScript does. runTest(() { @@ -115,20 +108,20 @@ void runSpecialSelectorTests(String type, root) { "This should find one element with the tag name 'UNDEFINED'."); }, '$type.querySelectorAll undefined'); - runTest(() { - // 3 - assertThrows((e) => e is NoSuchMethodError, () { - root.querySelectorAll(); - }, 'This should throw a TypeError.'); - }, '$type.querySelectorAll no parameter'); + // runTest(() { + // // 3 + // assertThrows((e) => e is NoSuchMethodError, () { + // root.querySelectorAll(); + // }, 'This should throw a TypeError.'); + // }, '$type.querySelectorAll no parameter'); runTest(() { // 4 final elm = root.querySelector('null'); assertNotEquals(elm, null, 'This should find an element.'); // TODO(jmesserly): change "localName" back to "tagName" once implemented. - assertEquals( - elm.localName.toUpperCase(), 'NULL', "The tag name should be 'NULL'."); + assertEquals(elm!.localName?.toUpperCase(), 'NULL', + "The tag name should be 'NULL'."); }, '$type.querySelector null'); runTest(() { @@ -136,23 +129,23 @@ void runSpecialSelectorTests(String type, root) { final elm = root.querySelector('undefined'); assertNotEquals(elm, 'undefined', 'This should find an element.'); // TODO(jmesserly): change "localName" back to "tagName" once implemented. - assertEquals(elm.localName.toUpperCase(), 'UNDEFINED', + assertEquals(elm!.localName?.toUpperCase(), 'UNDEFINED', "The tag name should be 'UNDEFINED'."); }, '$type.querySelector undefined'); - runTest(() { - // 6 - assertThrows((e) => e is NoSuchMethodError, () { - root.querySelector(); - }, 'This should throw a TypeError.'); - }, '$type.querySelector no parameter'); + // runTest(() { + // // 6 + // assertThrows((e) => e is NoSuchMethodError, () { + // root.querySelector(); + // }, 'This should throw a TypeError.'); + // }, '$type.querySelector no parameter'); runTest(() { // 7 final result = root.querySelectorAll('*'); var i = 0; - traverse(root as Node, (elem) { - if (!identical(elem, root)) { + traverse(root.asNode!, (elem) { + if (!identical(elem, root.asNode)) { assertEquals( elem, result[i], 'The result in index $i should be in tree order.'); i++; @@ -175,8 +168,8 @@ String? _getSkip(String name) { * Execute queries with the specified valid selectors for both querySelector() and querySelectorAll() * Only run these tests when results are expected. Don't run for syntax error tests. */ -void runValidSelectorTest(String type, Node root, - List> selectors, testType, docType) { +void runValidSelectorTest(String type, SelectorAdaptor root, + List> selectors, int testType, String docType) { var nodeType = ''; switch (root.nodeType) { case Node.DOCUMENT_NODE: @@ -199,16 +192,17 @@ void runValidSelectorTest(String type, Node root, final q = s['selector'] as String; final e = s['expect'] as List?; - if ((s['exclude'] is! List || - (s['exclude'].indexOf(nodeType) == -1 && - s['exclude'].indexOf(docType) == -1)) && - (s['testType'] & testType != 0)) { + final exclude = s['exclude']; + + if ((exclude is! List || + (!(exclude).contains(nodeType) && !exclude.contains(docType))) && + ((s['testType'] as int) & testType != 0)) { //console.log("Running tests " + nodeType + ": " + s["testType"] + "&" + testType + "=" + (s["testType"] & testType) + ": " + JSON.stringify(s)) late List foundall; Element? found; runTest(() { - foundall = (root as dynamic).querySelectorAll(q) as List; + foundall = root.querySelectorAll(q); assertNotEquals(foundall, null, 'The method should not return null.'); assertEquals(foundall.length, e!.length, 'The method should return the expected number of matches.'); @@ -224,7 +218,7 @@ void runValidSelectorTest(String type, Node root, }, '$type.querySelectorAll: $n:$q', skip: skip); runTest(() { - found = (root as dynamic).querySelector(q) as Element?; + found = root.querySelector(q); if (e!.isNotEmpty) { assertNotEquals(found, null, 'The method should return a match.'); @@ -248,7 +242,8 @@ void runValidSelectorTest(String type, Node root, * Execute queries with the specified invalid selectors for both querySelector() and querySelectorAll() * Only run these tests when errors are expected. Don't run for valid selector tests. */ -void runInvalidSelectorTest(String type, root, List selectors) { +void runInvalidSelectorTest( + String type, SelectorAdaptor root, List> selectors) { for (var i = 0; i < selectors.length; i++) { final s = selectors[i]; final n = s['name'] as String; @@ -256,13 +251,13 @@ void runInvalidSelectorTest(String type, root, List selectors) { // Dart note: FormatException seems a reasonable mapping of SyntaxError runTest(() { - assertThrows((e) => e is FormatException, () { + assertThrows((Object e) => e is FormatException, () { root.querySelector(q); }); }, '$type.querySelector: $n:$q'); runTest(() { - assertThrows((e) => e is FormatException, () { + assertThrows((Object e) => e is FormatException, () { root.querySelectorAll(q); }); }, '$type.querySelectorAll: $n:$q'); @@ -289,10 +284,64 @@ void assertTrue(bool value, String reason) => void assertFalse(bool value, String reason) => unittest.expect(value, unittest.isFalse, reason: reason); -void assertEquals(x, y, String reason) => unittest.expect(x, y, reason: reason); +void assertEquals(dynamic x, dynamic y, String reason) => + unittest.expect(x, y, reason: reason); -void assertNotEquals(x, y, String reason) => +void assertNotEquals(dynamic x, dynamic y, String reason) => unittest.expect(x, unittest.isNot(y), reason: reason); -void assertThrows(exception, void Function() body, [String? reason]) => +void assertThrows(Object exception, void Function() body, [String? reason]) => unittest.expect(body, unittest.throwsA(exception), reason: reason); + +/// Used for testing. +/// +/// This class delegates to one of three different kinds of objects. They share +/// methods with similar signatures but do not share a type hierarchy. +/// Previously these methods were invoked through `dynamic`. +class SelectorAdaptor { + final Document? document; + final Element? element; + final DocumentFragment? fragment; + + SelectorAdaptor.document(this.document) + : element = null, + fragment = null; + + SelectorAdaptor.element(this.element) + : document = null, + fragment = null; + + SelectorAdaptor.fragment(this.fragment) + : document = null, + element = null; + + bool get isDocument => document != null; + + Element? get body => document?.body; + + Node? get asNode => document ?? element ?? fragment; + + int get nodeType => asNode!.nodeType; + + Node? get parentNode => asNode!.parentNode; + + void append(Node node) { + asNode!.append(node); + } + + Element? querySelector(String selector) { + if (document != null) return document!.querySelector(selector); + if (element != null) return element!.querySelector(selector); + if (fragment != null) return fragment!.querySelector(selector); + + throw StateError('unsupported'); + } + + List querySelectorAll(String selector) { + if (document != null) return document!.querySelectorAll(selector); + if (element != null) return element!.querySelectorAll(selector); + if (fragment != null) return fragment!.querySelectorAll(selector); + + throw StateError('unsupported'); + } +} diff --git a/test/selectors/selectors.dart b/test/selectors/selectors.dart index 289cfda..93d91cd 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 -final testQsaBaseline = +final int testQsaBaseline = 0x01; // querySelector() and querySelectorAll() baseline tests -final testQsaAdditional = +final int testQsaAdditional = 0x02; // querySelector() and querySelectorAll() additional tests -final testFindBaseline = +final int testFindBaseline = 0x04; // find() and findAll() baseline tests, may be unsuitable for querySelector[All] -final testFindAdditional = +final int testFindAdditional = 0x08; // find() and findAll() additional tests, may be unsuitable for querySelector[All] -final testMatchBaseline = 0x10; // matches() baseline tests -var testMatchAdditional = 0x20; // matches() additional tests +final int testMatchBaseline = 0x10; // matches() baseline tests +int testMatchAdditional = 0x20; // matches() additional tests /* * All of these invalid selectors should result in a SyntaxError being thrown by the APIs. @@ -74,7 +74,7 @@ final invalidSelectors = [ * * Note: Interactive pseudo-classes (:active :hover and :focus) have not been tested in this test suite. */ -var validSelectors = [ +final List> validSelectors = [ // Type Selector { 'name': 'Type selector, matching html element', @@ -87,7 +87,7 @@ var validSelectors = [ { 'name': 'Type selector, matching html element', 'selector': 'html', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'exclude': ['document'], 'level': 1, 'testType': testQsaBaseline @@ -103,7 +103,7 @@ var validSelectors = [ { 'name': 'Type selector, matching body element', 'selector': 'body', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'exclude': ['document'], 'level': 1, 'testType': testQsaBaseline @@ -142,7 +142,7 @@ var validSelectors = [ 'name': 'Universal selector, matching all children of empty element with specified ID', 'selector': '#empty>*', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -196,7 +196,7 @@ var validSelectors = [ 'name': 'Attribute presence selector, not matching title attribute, case sensitivity', 'selector': '#attr-presence [TiTlE]', - 'expect': [], + 'expect': [], 'exclude': ['html'], 'level': 2, 'testType': testQsaBaseline | testMatchBaseline @@ -212,7 +212,7 @@ var validSelectors = [ 'name': 'Attribute presence selector, not matching attribute with similar name', 'selector': '.attr-presence-div3[align], .attr-presence-div4[align]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -228,7 +228,7 @@ var validSelectors = [ 'name': 'Attribute presence selector, not matching default option without selected attribute', 'selector': '#attr-presence-select1 option[selected]', - 'expect': [] /* no matches */, + 'expect': [] /* no matches */, 'level': 2, 'testType': testQsaBaseline }, @@ -272,7 +272,7 @@ var validSelectors = [ 'name': 'Attribute value selector, not matching align attribute with partial value', 'selector': '#attr-value [align="c"]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -280,7 +280,7 @@ var validSelectors = [ 'name': 'Attribute value selector, not matching align attribute with incorrect value', 'selector': '#attr-value [align="centera"]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -366,7 +366,7 @@ var validSelectors = [ 'name': 'Attribute whitespace-separated list selector, not matching class attribute with empty value', 'selector': '#attr-whitespace [class~=""]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -374,7 +374,7 @@ var validSelectors = [ 'name': 'Attribute whitespace-separated list selector, not matching class attribute with partial value', 'selector': '[data-attr-whitespace~="div"]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -443,7 +443,7 @@ var validSelectors = [ 'name': 'Attribute whitespace-separated list selector with double-quoted value, not matching value with space', 'selector': '#attr-whitespace a[rel~="book mark"]', - 'expect': [] /* no matches */, + 'expect': [] /* no matches */, 'level': 2, 'testType': testQsaBaseline }, @@ -461,7 +461,7 @@ var validSelectors = [ 'name': 'Attribute hyphen-separated list selector, not matching unspecified lang attribute', 'selector': '#attr-hyphen-div1[lang|="en"]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -485,7 +485,7 @@ var validSelectors = [ 'name': 'Attribute hyphen-separated list selector, not matching incorrect value', 'selector': '#attr-hyphen-div4[lang|="es-AR"]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -511,7 +511,7 @@ var validSelectors = [ 'name': 'Attribute begins with selector, not matching class attribute not beginning with specified substring', 'selector': '#attr-begins [class^=apple]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -535,7 +535,7 @@ var validSelectors = [ 'name': 'Attribute begins with selector with unquoted value, not matching class attribute not beginning with specified substring', 'selector': '#attr-begins [class^= apple]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -561,7 +561,7 @@ var validSelectors = [ 'name': 'Attribute ends with selector, not matching class attribute not ending with specified substring', 'selector': '#attr-ends [class\$=apple]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -585,7 +585,7 @@ var validSelectors = [ 'name': 'Attribute ends with selector with unquoted value, not matching class attribute not ending with specified substring', 'selector': '#attr-ends [class\$=apple ]', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -717,7 +717,7 @@ var validSelectors = [ { 'name': ':root pseudo-class selector, not matching document root element', 'selector': ':root', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'exclude': ['document'], 'level': 3, 'testType': testQsaAdditional @@ -946,7 +946,7 @@ var validSelectors = [ ":first-child pseudo-class selector, doesn't match non-first-child elements", 'selector': '.pseudo-first-child-div2:first-child, .pseudo-first-child-div3:first-child', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -977,7 +977,7 @@ var validSelectors = [ ":last-child pseudo-class selector, doesn't match non-last-child elements", 'selector': '.pseudo-last-child-div1:last-child, .pseudo-last-child-div2:first-child', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -1007,7 +1007,7 @@ var validSelectors = [ 'name': ':pseudo-only-child pseudo-class selector, matching only-child em elements', 'selector': '#pseudo-only em:only-child', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -1070,7 +1070,7 @@ var validSelectors = [ 'name': ':link and :visited pseudo-class selectors, not matching link elements with href attributes', 'selector': '#head :link, #head :visited', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'exclude': ['document'], 'level': 1, 'testType': testQsaBaseline @@ -1079,7 +1079,7 @@ var validSelectors = [ 'name': ':link and :visited pseudo-class selectors, chained, mutually exclusive pseudo-classes match nothing', 'selector': ':link:visited', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'exclude': ['document'], 'level': 1, 'testType': testQsaBaseline @@ -1090,7 +1090,7 @@ var validSelectors = [ 'name': ':target pseudo-class selector, matching the element referenced by the URL fragment identifier', 'selector': ':target', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'exclude': ['document', 'element'], 'level': 3, 'testType': testQsaAdditional @@ -1118,7 +1118,7 @@ var validSelectors = [ 'name': ':lang pseudo-class selector, not matching element with no inherited language', 'selector': '#pseudo-lang-div1:lang(en)', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'exclude': ['document', 'element'], 'level': 2, 'testType': testQsaBaseline @@ -1142,7 +1142,7 @@ var validSelectors = [ { 'name': ':lang pseudo-class selector, not matching incorrect language', 'selector': '#pseudo-lang-div4:lang(es-AR)', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1224,14 +1224,14 @@ var validSelectors = [ { 'name': ':not pseudo-class selector, matching nothing', 'selector': ':not(*)', - 'expect': [] /* no matches */, + 'expect': [] /* no matches */, 'level': 3, 'testType': testQsaAdditional }, { 'name': ':not pseudo-class selector, matching nothing', 'selector': ':not(*|*)', - 'expect': [] /* no matches */, + 'expect': [] /* no matches */, 'level': 3, 'testType': testQsaAdditional }, @@ -1242,7 +1242,7 @@ var validSelectors = [ 'name': ':first-line pseudo-element (one-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element:first-line', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1250,7 +1250,7 @@ var validSelectors = [ 'name': '::first-line pseudo-element (two-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element::first-line', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -1260,7 +1260,7 @@ var validSelectors = [ 'name': ':first-letter pseudo-element (one-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element:first-letter', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1268,7 +1268,7 @@ var validSelectors = [ 'name': '::first-letter pseudo-element (two-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element::first-letter', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -1278,7 +1278,7 @@ var validSelectors = [ 'name': ':before pseudo-element (one-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element:before', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1286,7 +1286,7 @@ var validSelectors = [ 'name': '::before pseudo-element (two-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element::before', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -1296,7 +1296,7 @@ var validSelectors = [ 'name': ':after pseudo-element (one-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element:after', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1304,7 +1304,7 @@ var validSelectors = [ 'name': '::after pseudo-element (two-colon syntax) selector, not matching any elements', 'selector': '#pseudo-element::after', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -1413,14 +1413,14 @@ var validSelectors = [ { 'name': 'ID selector, not matching non-existent descendant', 'selector': '#id #none', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 1, 'testType': testQsaBaseline }, { 'name': 'ID selector, not matching non-existent ancestor', 'selector': '#none #id-div1', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 1, 'testType': testQsaBaseline }, @@ -1565,7 +1565,7 @@ var validSelectors = [ 'name': 'Descendant combinator, not matching element with id that is not a descendant of an element with id', 'selector': '#descendant-div1 #descendant-div4', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 1, 'testType': testQsaBaseline }, @@ -1622,7 +1622,7 @@ var validSelectors = [ 'name': 'Child combinator, not matching element with id that is not a child of an element with id', 'selector': '#child>#child-div3', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1630,7 +1630,7 @@ var validSelectors = [ 'name': 'Child combinator, not matching element with id that is not a child of an element with class', 'selector': '#child-div1>.child-div3', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1638,7 +1638,7 @@ var validSelectors = [ 'name': 'Child combinator, not matching element with class that is not a child of an element with class', 'selector': '.child-div1>.child-div3', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1724,7 +1724,7 @@ var validSelectors = [ 'name': 'Adjacent sibling combinator, not matching element with id that is not an adjacent sibling of an element with id', 'selector': '#adjacent-div2+#adjacent-p2, #adjacent-div2+#adjacent-div1', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 2, 'testType': testQsaBaseline }, @@ -1802,7 +1802,7 @@ var validSelectors = [ 'name': 'General sibling combinator, not matching element with id that is not a sibling after a p element', 'selector': '#sibling>p~div', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, @@ -1810,7 +1810,7 @@ var validSelectors = [ 'name': 'General sibling combinator, not matching element with id that is not a sibling after an element with id', 'selector': '#sibling-div2~#sibling-div3, #sibling-div2~#sibling-div1', - 'expect': [] /*no matches*/, + 'expect': [] /*no matches*/, 'level': 3, 'testType': testQsaAdditional }, diff --git a/test/support.dart b/test/support.dart index f4f48f8..a74242c 100644 --- a/test/support.dart +++ b/test/support.dart @@ -15,7 +15,7 @@ typedef TreeBuilderFactory = TreeBuilder Function(bool namespaceHTMLElements); Map? _treeTypes; Map? get treeTypes { // TODO(jmesserly): add DOM here once it's implemented - _treeTypes ??= {'simpletree': (useNs) => TreeBuilder(useNs)}; + _treeTypes ??= {'simpletree': TreeBuilder.new}; return _treeTypes; } @@ -144,7 +144,7 @@ class TestSerializer extends TreeVisitor { } @override - void visitDocument(node) => _visitDocumentOrFragment(node); + void visitDocument(Document node) => _visitDocumentOrFragment(node); void _visitDocumentOrFragment(Node node) { indent += 1; diff --git a/test/tokenizer_test.dart b/test/tokenizer_test.dart index e0af7fb..d804184 100644 --- a/test/tokenizer_test.dart +++ b/test/tokenizer_test.dart @@ -1,13 +1,10 @@ @TestOn('vm') library tokenizer_test; -// TODO(https://github.com/dart-lang/html/issues/173): Remove. -// ignore_for_file: avoid_dynamic_calls - -// Note: mirrors used to match the getattr usage in the original test import 'dart:convert'; import 'dart:io'; -import 'dart:mirrors'; +// Note: mirrors used to match the getattr usage in the original test +import 'dart:mirrors' show reflect; import 'package:html/src/token.dart'; import 'package:html/src/tokenizer.dart'; @@ -16,11 +13,37 @@ import 'package:test/test.dart'; import 'support.dart'; +void main() async { + await for (var path in dataFiles('tokenizer')) { + if (!path.endsWith('.test')) continue; + + final text = File(path).readAsStringSync(); + final tests = jsonDecode(text) as Map; + final testName = pathos.basenameWithoutExtension(path); + final testList = tests['tests'] as List?; + if (testList == null) continue; + + group(testName, () { + for (var index = 0; index < testList.length; index++) { + final testInfo = testList[index] as Map; + + testInfo.putIfAbsent('initialStates', () => ['Data state']); + for (var initialState in testInfo['initialStates'] as List) { + test(testInfo['description'], () { + testInfo['initialState'] = camelCase(initialState as String); + runTokenizerTest(testInfo); + }); + } + } + }); + } +} + class TokenizerTestParser { final String? _state; final String? _lastStartTag; final bool _generateSpans; - List? outputTokens; + List>? outputTokens; TokenizerTestParser(String? initialState, [String? lastStartTag, bool generateSpans = false]) @@ -28,7 +51,7 @@ class TokenizerTestParser { _lastStartTag = lastStartTag, _generateSpans = generateSpans; - List? parse(String str) { + List? parse(String str) { // Note: we need to pass bytes to the tokenizer if we want it to handle BOM. final bytes = utf8.encode(str); final tokenizer = @@ -101,7 +124,7 @@ class TokenizerTestParser { addOutputToken(token, ['Character', token.data]); } - void processEOF(token) {} + void processEOF(StringToken token) {} void processParseError(StringToken token) { // TODO(jmesserly): when debugging test failures it can be useful to add @@ -110,7 +133,7 @@ class TokenizerTestParser { addOutputToken(token, ['ParseError', token.data]); } - void addOutputToken(Token token, List array) { + void addOutputToken(Token token, List array) { outputTokens!.add([ ...array, if (token.span != null && _generateSpans) token.span!.start.offset, @@ -119,14 +142,16 @@ class TokenizerTestParser { } } -List concatenateCharacterTokens(List tokens) { - final outputTokens = []; +/// [tokens] can contain strings, lists, and maps. +List concatenateCharacterTokens(List tokens) { + final outputTokens = []; for (var token in tokens) { - if (token.indexOf('ParseError') == -1 && token[0] == 'Character') { + if (token != 'ParseError' && (token as List)[0] == 'Character') { if (outputTokens.isNotEmpty && - outputTokens.last.indexOf('ParseError') == -1 && - outputTokens.last[0] == 'Character') { - outputTokens.last[1] = '${outputTokens.last[1]}${token[1]}'; + outputTokens.last != 'ParseError' && + (outputTokens.last as List)[0] == 'Character') { + (outputTokens.last as List)[1] = + '${(outputTokens.last as List)[1]}${token[1]}'; } else { outputTokens.add(token); } @@ -137,10 +162,10 @@ List concatenateCharacterTokens(List tokens) { return outputTokens; } -List normalizeTokens(List tokens) { +List normalizeTokens(List tokens) { // TODO: convert tests to reflect arrays for (var i = 0; i < tokens.length; i++) { - final token = tokens[i]; + final token = tokens[i] as List; if (token[0] == 'ParseError') { tokens[i] = token[0]; } @@ -152,13 +177,13 @@ List normalizeTokens(List tokens) { /// /// If the ignoreErrorOrder flag is set to true we don't test the relative /// positions of parse errors and non parse errors. -void expectTokensMatch( - List expectedTokens, List receivedTokens, bool ignoreErrorOrder, +void expectTokensMatch(List expectedTokens, + List receivedTokens, bool ignoreErrorOrder, [bool ignoreErrors = false, String? message]) { // If the 'selfClosing' attribute is not included in the expected test tokens, // remove it from the received token. var removeSelfClosing = false; - for (var token in expectedTokens) { + for (var token in expectedTokens.whereType>()) { if (token[0] == 'StartTag' && token.length == 3 || token[0] == 'EndTag' && token.length == 2) { removeSelfClosing = true; @@ -167,7 +192,7 @@ void expectTokensMatch( } if (removeSelfClosing) { - for (var token in receivedTokens) { + for (var token in receivedTokens.whereType>()) { if (token[0] == 'StartTag' || token[0] == 'EndTag') { token.removeLast(); } @@ -229,24 +254,30 @@ Map unescape(Map testInfo) { // TODO(sigmundch,jmesserly): we currently use jsonDecode to unescape the // unicode characters in the string, we should use a decoding that works with // any control characters. - dynamic decode(inp) => inp == '\u0000' ? inp : jsonDecode('"$inp"'); + dynamic decode(String inp) => inp == '\u0000' ? inp : jsonDecode('"$inp"'); + + testInfo['input'] = decode(testInfo['input'] as String); - testInfo['input'] = decode(testInfo['input']); for (var token in testInfo['output'] as List) { if (token == 'ParseError') { continue; - } else { - token[1] = decode(token[1]); - if ((token as List).length > 2) { - for (var pair in token[2] as List) { - final key = pair[0]; - final value = pair[1]; - token[2].remove(key); - token[2][decode(key)] = decode(value); - } + } + + token as List; + token[1] = decode(token[1] as String); + + if ((token).length > 2) { + for (var pair in (token[2] as List)) { + pair as List; + final key = pair[0] as String; + final value = pair[1] as String; + + (token[2] as Map).remove(key); + (token[2] as Map)[decode(key)] = decode(value); } } } + return testInfo; } @@ -260,29 +291,3 @@ String camelCase(String s) { } return result.toString(); } - -void main() async { - await for (var path in dataFiles('tokenizer')) { - if (!path.endsWith('.test')) continue; - - final text = File(path).readAsStringSync(); - final tests = jsonDecode(text); - final testName = pathos.basenameWithoutExtension(path); - final testList = tests['tests'] as List?; - if (testList == null) continue; - - group(testName, () { - for (var index = 0; index < testList.length; index++) { - final testInfo = testList[index] as Map; - - testInfo.putIfAbsent('initialStates', () => ['Data state']); - for (var initialState in testInfo['initialStates'] as List) { - test(testInfo['description'], () { - testInfo['initialState'] = camelCase(initialState as String); - runTokenizerTest(testInfo); - }); - } - } - }); - } -} From 776daf531974258561b8229be7bd8a901f414658 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 30 Jan 2023 07:40:00 -0800 Subject: [PATCH 09/33] Update test-package.yml (#198) --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 8421e30..413bb30 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -2,9 +2,9 @@ name: Dart CI on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] schedule: - cron: "0 0 * * 0" From fe3fbf632297b8f11b71763c0d5ca83ce21095ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 08:40:22 -0800 Subject: [PATCH 10/33] Bump dart-lang/setup-dart from 1.3 to 1.4 (#199) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.3 to 1.4. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/6a218f2413a3e78e9087f638a238f6b40893203d...a57a6c04cf7d4840e88432aad6281d1e125f0d46) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 413bb30..0ec49aa 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: dev - id: install @@ -35,7 +35,7 @@ jobs: sdk: [2.17.0, dev] steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From 9ab8b281a8cf39472b68fe365129e3e706d848e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 08:43:19 -0800 Subject: [PATCH 11/33] Bump actions/checkout from 3.2.0 to 3.3.0 (#200) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/755da8c3cf115ac066823e79a1e1788f8940201b...ac593985615ec2ede58e132d2e21d2b1cbd6127c) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 0ec49aa..0610b92 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From 71d3e71bcf31f931c769a87f392b3f513b6ae3fc Mon Sep 17 00:00:00 2001 From: Ron Booth Date: Mon, 30 Jan 2023 15:15:24 -0700 Subject: [PATCH 12/33] fixed issue #157 (querySelector fails), and added test for it (#158) --- lib/src/query_selector.dart | 35 +++++++++++++++++++---------------- test/query_selector_test.dart | 26 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 test/query_selector_test.dart diff --git a/lib/src/query_selector.dart b/lib/src/query_selector.dart index 32e0a37..c45d11c 100644 --- a/lib/src/query_selector.dart +++ b/lib/src/query_selector.dart @@ -69,22 +69,25 @@ class SelectorEvaluator extends Visitor { for (var s in node.simpleSelectorSequences.reversed) { if (combinator == null) { result = s.simpleSelector.visit(this) as bool; - } else if (combinator == TokenKind.COMBINATOR_DESCENDANT) { - // descendant combinator - // http://dev.w3.org/csswg/selectors-4/#descendant-combinators - do { - _element = _element!.parent; - } while (_element != null && !(s.simpleSelector.visit(this) as bool)); - - if (_element == null) result = false; - } else if (combinator == TokenKind.COMBINATOR_TILDE) { - // Following-sibling combinator - // http://dev.w3.org/csswg/selectors-4/#general-sibling-combinators - do { - _element = _element!.previousElementSibling; - } while (_element != null && !(s.simpleSelector.visit(this) as bool)); - - if (_element == null) result = false; + } else { + if (combinator == TokenKind.COMBINATOR_DESCENDANT) { + // descendant combinator + // http://dev.w3.org/csswg/selectors-4/#descendant-combinators + do { + _element = _element!.parent; + } while (_element != null && !(s.simpleSelector.visit(this) as bool)); + + if (_element == null) result = false; + } else if (combinator == TokenKind.COMBINATOR_TILDE) { + // Following-sibling combinator + // http://dev.w3.org/csswg/selectors-4/#general-sibling-combinators + do { + _element = _element!.previousElementSibling; + } while (_element != null && !(s.simpleSelector.visit(this) as bool)); + + if (_element == null) result = false; + } + combinator = null; } if (!result) break; diff --git a/test/query_selector_test.dart b/test/query_selector_test.dart new file mode 100644 index 0000000..9b81e93 --- /dev/null +++ b/test/query_selector_test.dart @@ -0,0 +1,26 @@ +library query_selector_test; + +import 'package:test/test.dart'; +import 'package:html/dom.dart'; + +void main() { + group('querySelector descendant', () { + late Element el; + + setUp(() { + el = Element.html('
'); + }); + + test('descendant of type', () { + expect(el.querySelector('div div')?.id, 'b'); + }); + + test('descendant of class', () { + expect(el.querySelector('.a div')?.id, 'b'); + }); + + test('descendant of type and class', () { + expect(el.querySelector('div.a div')?.id, 'b'); + }); + }); +} From 52d9185520bfc415a4cf0d6d6516189293f54a7b Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 30 Jan 2023 15:31:21 -0800 Subject: [PATCH 13/33] updates from #158 (#202) * updates from #158 * typo --- CHANGELOG.md | 2 ++ test/query_selector_test.dart | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0adcd1a..6124708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - Add additional types at the API boundary (in `lib/parser.dart` and others). - Update to `package:lints` 2.0. +- Fixed an issue with `querySelector` where it would fail in some cases with + descendant or sibling combinators (#157). ## 0.15.1 diff --git a/test/query_selector_test.dart b/test/query_selector_test.dart index 9b81e93..149250f 100644 --- a/test/query_selector_test.dart +++ b/test/query_selector_test.dart @@ -1,7 +1,7 @@ library query_selector_test; -import 'package:test/test.dart'; import 'package:html/dom.dart'; +import 'package:test/test.dart'; void main() { group('querySelector descendant', () { From f118e004dfe68a4d101246106e775c0231efb79a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 30 Jan 2023 15:49:51 -0800 Subject: [PATCH 14/33] lint with dart_flutter_team_lints (#201) --- CHANGELOG.md | 2 +- analysis_options.yaml | 43 ++-------------------------------- lib/dom.dart | 2 +- lib/parser.dart | 14 +++++------ lib/src/constants.dart | 2 +- lib/src/encoding_parser.dart | 27 ++++++++++++--------- lib/src/html_input_stream.dart | 2 +- pubspec.yaml | 2 +- test/selectors/level1_lib.dart | 2 +- test/tokenizer_test.dart | 4 ++-- 10 files changed, 33 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6124708..2588fea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.15.2-dev - Add additional types at the API boundary (in `lib/parser.dart` and others). -- Update to `package:lints` 2.0. +- Adopted the `package:dart_flutter_team_lints` linting rules. - Fixed an issue with `querySelector` where it would fail in some cases with descendant or sibling combinators (#157). diff --git a/analysis_options.yaml b/analysis_options.yaml index 715ea40..90d920e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,49 +1,10 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-casts: true strict-raw-types: true errors: + lines_longer_than_80_chars: ignore # https://github.com/dart-lang/linter/issues/1649 prefer_collection_literals: ignore - -linter: - rules: - - always_declare_return_types - - avoid_dynamic_calls - - avoid_function_literals_in_foreach_calls - - avoid_returning_null - - avoid_unused_constructor_parameters - - await_only_futures - - camel_case_types - - cancel_subscriptions - - comment_references - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - iterable_contains_unrelated_type - - list_remove_unrelated_type - - no_adjacent_strings_in_list - - non_constant_identifier_names - - only_throw_errors - - overridden_fields - - package_api_docs - - package_names - - package_prefixed_library_names - - prefer_const_constructors - - prefer_final_locals - - prefer_initializing_formals - - prefer_interpolation_to_compose_strings - - prefer_typing_uninitialized_variables - - test_types_in_equals - - throw_in_finally - - type_annotate_public_apis - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_lambdas - - unnecessary_null_aware_assignments - - unnecessary_statements diff --git a/lib/dom.dart b/lib/dom.dart index 5ffc15f..28d7594 100644 --- a/lib/dom.dart +++ b/lib/dom.dart @@ -60,7 +60,7 @@ class AttributeName implements Comparable { int compareTo(Object other) { // Not sure about this sort order if (other is! AttributeName) return 1; - var cmp = (prefix ?? '').compareTo((other.prefix ?? '')); + var cmp = (prefix ?? '').compareTo(other.prefix ?? ''); if (cmp != 0) return cmp; cmp = name.compareTo(other.name); if (cmp != 0) return cmp; diff --git a/lib/parser.dart b/lib/parser.dart index c4bd1ed..3eb7a97 100644 --- a/lib/parser.dart +++ b/lib/parser.dart @@ -151,7 +151,7 @@ class HtmlParser { String? sourceUrl, TreeBuilder? tree}) : tree = tree ?? TreeBuilder(true), - tokenizer = (input is HtmlTokenizer + tokenizer = input is HtmlTokenizer ? input : HtmlTokenizer(input, encoding: encoding, @@ -159,7 +159,7 @@ class HtmlParser { lowercaseElementName: lowercaseElementName, lowercaseAttrName: lowercaseAttrName, generateSpans: generateSpans, - sourceUrl: sourceUrl)) { + sourceUrl: sourceUrl) { tokenizer.parser = this; } @@ -653,9 +653,9 @@ class InitialPhase extends Phase { final systemId = token.systemId; final correct = token.correct; - if ((name != 'html' || + if (name != 'html' || publicId != null || - systemId != null && systemId != 'about:legacy-compat')) { + systemId != null && systemId != 'about:legacy-compat') { parser.parseError(token.span, 'unknown-doctype'); } @@ -1573,8 +1573,8 @@ class InBodyPhase extends Phase { void startTagFrameset(StartTagToken token) { parser.parseError(token.span, 'unexpected-start-tag', {'name': 'frameset'}); - if ((tree.openElements.length == 1 || - tree.openElements[1].localName != 'body')) { + if (tree.openElements.length == 1 || + tree.openElements[1].localName != 'body') { assert(parser.innerHTMLMode); } else if (parser.framesetOK) { if (tree.openElements[1].parentNode != null) { @@ -2121,7 +2121,7 @@ class InBodyPhase extends Phase { } // Step 6.4 if (lastNode == furthestBlock) { - bookmark = (tree.activeFormattingElements.indexOf(node) + 1); + bookmark = tree.activeFormattingElements.indexOf(node) + 1; } // Step 6.5 //cite = node.parent diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 152f85b..5c41f81 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -200,7 +200,7 @@ const Map errorMessages = { 'unexpected-end-tag-after-body': 'Unexpected end tag token (%(name)s)' ' in the after body phase.', 'unexpected-char-in-frameset': - 'Unepxected characters in the frameset phase. Characters ignored.', + 'Unexpected characters in the frameset phase. Characters ignored.', 'unexpected-start-tag-in-frameset': 'Unexpected start tag token (%(name)s)' ' in the frameset phase. Ignored.', 'unexpected-frameset-in-frameset-innerhtml': diff --git a/lib/src/encoding_parser.dart b/lib/src/encoding_parser.dart index defe57e..2ecd5c4 100644 --- a/lib/src/encoding_parser.dart +++ b/lib/src/encoding_parser.dart @@ -1,9 +1,8 @@ import 'constants.dart'; import 'html_input_stream.dart'; -// TODO(jmesserly): I converted StopIteration to StateError("No more elements"). -// Seems strange to throw this from outside of an iterator though. -/// String-like object with an associated position and various extra methods +/// String-like object with an associated position and various extra methods. +/// /// If the position is ever greater than the string length then an exception is /// raised. class EncodingBytes { @@ -17,7 +16,7 @@ class EncodingBytes { String _next() { final p = __position = __position + 1; if (p >= _length) { - throw StateError('No more elements'); + throw _EncodingRangeException('No more elements'); } else if (p < 0) { throw RangeError(p); } @@ -27,7 +26,7 @@ class EncodingBytes { String _previous() { var p = __position; if (p >= _length) { - throw StateError('No more elements'); + throw _EncodingRangeException('No more elements'); } else if (p < 0) { throw RangeError(p); } @@ -37,14 +36,14 @@ class EncodingBytes { set _position(int value) { if (__position >= _length) { - throw StateError('No more elements'); + throw _EncodingRangeException('No more elements'); } __position = value; } int get _position { if (__position >= _length) { - throw StateError('No more elements'); + throw _EncodingRangeException('No more elements'); } if (__position >= 0) { return __position; @@ -108,7 +107,7 @@ class EncodingBytes { __position = newPosition + bytes.length - 1; return true; } else { - throw StateError('No more elements'); + throw _EncodingRangeException('No more elements'); } } @@ -161,7 +160,7 @@ class EncodingParser { } _data._position += 1; } - } on StateError catch (_) { + } on _EncodingRangeException catch (_) { // Catch this here to match behavior of Python's StopIteration // TODO(jmesserly): refactor to not use exceptions } @@ -355,12 +354,12 @@ class ContentAttrParser { try { data._skipUntil(isWhitespace); return data._slice(oldPosition, data._position); - } on StateError catch (_) { + } on _EncodingRangeException catch (_) { //Return the whole remaining value return data._slice(oldPosition); } } - } on StateError catch (_) { + } on _EncodingRangeException catch (_) { return null; } } @@ -371,3 +370,9 @@ bool _isSpaceOrAngleBracket(String char) { } typedef _CharPredicate = bool Function(String char); + +class _EncodingRangeException implements Exception { + final String message; + + _EncodingRangeException(this.message); +} diff --git a/lib/src/html_input_stream.dart b/lib/src/html_input_stream.dart index 54e0231..1c1bcc8 100644 --- a/lib/src/html_input_stream.dart +++ b/lib/src/html_input_stream.dart @@ -22,7 +22,7 @@ class HtmlInputStream { /// The name of the character encoding. String? charEncodingName; - /// True if we are certain about [charEncodingName], false for tenative. + /// True if we are certain about [charEncodingName], false for tentative. bool charEncodingCertain = true; final bool generateSpans; diff --git a/pubspec.yaml b/pubspec.yaml index 831bce0..2a61ef4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,6 @@ dependencies: source_span: ^1.8.0 dev_dependencies: - lints: ^2.0.0 + dart_flutter_team_lints: ^0.1.0 path: ^1.8.0 test: ^1.16.0 diff --git a/test/selectors/level1_lib.dart b/test/selectors/level1_lib.dart index 2f62103..833e702 100644 --- a/test/selectors/level1_lib.dart +++ b/test/selectors/level1_lib.dart @@ -195,7 +195,7 @@ void runValidSelectorTest(String type, SelectorAdaptor root, final exclude = s['exclude']; if ((exclude is! List || - (!(exclude).contains(nodeType) && !exclude.contains(docType))) && + (!exclude.contains(nodeType) && !exclude.contains(docType))) && ((s['testType'] as int) & testType != 0)) { //console.log("Running tests " + nodeType + ": " + s["testType"] + "&" + testType + "=" + (s["testType"] & testType) + ": " + JSON.stringify(s)) late List foundall; diff --git a/test/tokenizer_test.dart b/test/tokenizer_test.dart index d804184..1281906 100644 --- a/test/tokenizer_test.dart +++ b/test/tokenizer_test.dart @@ -266,8 +266,8 @@ Map unescape(Map testInfo) { token as List; token[1] = decode(token[1] as String); - if ((token).length > 2) { - for (var pair in (token[2] as List)) { + if (token.length > 2) { + for (var pair in token[2] as List) { pair as List; final key = pair[0] as String; final value = pair[1] as String; From 0b8025c16e1e5a5bcd451fb3a81cd98df218dcd4 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Sat, 4 Feb 2023 19:41:37 -0800 Subject: [PATCH 15/33] add an api example (#204) --- CHANGELOG.md | 1 + README.md | 4 ++-- example/main.dart | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 example/main.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 2588fea..0e9440f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Adopted the `package:dart_flutter_team_lints` linting rules. - Fixed an issue with `querySelector` where it would fail in some cases with descendant or sibling combinators (#157). +- Add an API example in `example/`. ## 0.15.1 diff --git a/README.md b/README.md index f5388b2..05a19a8 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ A Dart implementation of an HTML5 parser. Parsing HTML is easy! ```dart -import 'package:html/parser.dart' show parse; +import 'package:html/parser.dart'; -main() { +void main() { var document = parse( 'Hello world! HTML5 rocks!'); print(document.outerHtml); diff --git a/example/main.dart b/example/main.dart new file mode 100644 index 0000000..309ed7c --- /dev/null +++ b/example/main.dart @@ -0,0 +1,57 @@ +import 'package:html/dom.dart'; +import 'package:html/dom_parsing.dart'; +import 'package:html/parser.dart'; + +void main(List args) { + var document = parse(''' + +

Header 1

+

Text.

+

Header 2

+ More text. +
+'''); + + // outerHtml output + print('outer html:'); + print(document.outerHtml); + + print(''); + + // visitor output + print('html visitor:'); + _Visitor().visit(document); +} + +// Note: this example visitor doesn't handle things like printing attributes and +// such. +class _Visitor extends TreeVisitor { + String indent = ''; + + @override + void visitText(Text node) { + if (node.data.trim().isNotEmpty) { + print('$indent${node.data.trim()}'); + } + } + + @override + void visitElement(Element node) { + if (isVoidElement(node.localName)) { + print('$indent<${node.localName}/>'); + } else { + print('$indent<${node.localName}>'); + indent += ' '; + visitChildren(node); + indent = indent.substring(0, indent.length - 2); + print('$indent'); + } + } + + @override + void visitChildren(Node node) { + for (var child in node.nodes) { + visit(child); + } + } +} From 08643e9e2baac0f20ce4a3b8baed820107972270 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 2 Mar 2023 11:36:59 -0800 Subject: [PATCH 16/33] prep for publishing 0.15.2 (#205) --- CHANGELOG.md | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9440f..725d157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.15.2-dev +## 0.15.2 - Add additional types at the API boundary (in `lib/parser.dart` and others). - Adopted the `package:dart_flutter_team_lints` linting rules. diff --git a/pubspec.yaml b/pubspec.yaml index 2a61ef4..eb222a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: html -version: 0.15.2-dev +version: 0.15.2 description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/html From 51c9910beca8c91772ae2ff1e970b6a1e7c0cfcb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:33:06 -0700 Subject: [PATCH 17/33] Bump actions/checkout from 3.3.0 to 3.5.0 (#210) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 0610b92..ea3601c 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From 57b747d7052aba08901adb366ffb2836facaa04d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:55:31 -0700 Subject: [PATCH 18/33] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#209) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/a57a6c04cf7d4840e88432aad6281d1e125f0d46...d6a63dab3335f427404425de0fbfed4686d93c4f) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index ea3601c..568b209 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: dev - id: install @@ -35,7 +35,7 @@ jobs: sdk: [2.17.0, dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From 0438b26b90be4d491ec55586b6b841f41e4fbf1e Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Wed, 5 Apr 2023 02:12:31 +0200 Subject: [PATCH 19/33] Dart 3 compatibility: turn classes into mixins (#208) These are private definitions and are only ever used in a `with` clause. They should just be changed to `mixin` to become compatible with Dart language 3.0. --- lib/dom.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dom.dart b/lib/dom.dart index 28d7594..5b8f8c9 100644 --- a/lib/dom.dart +++ b/lib/dom.dart @@ -76,7 +76,7 @@ class AttributeName implements Comparable { } // http://dom.spec.whatwg.org/#parentnode -abstract class _ParentNode implements Node { +mixin _ParentNode implements Node { // TODO(jmesserly): this is only a partial implementation /// Seaches for the first descendant node matching the given selectors, using @@ -103,7 +103,7 @@ abstract class _ParentNode implements Node { } // http://dom.spec.whatwg.org/#interface-nonelementparentnode -abstract class _NonElementParentNode implements _ParentNode { +mixin _NonElementParentNode implements _ParentNode { // TODO(jmesserly): could be faster, should throw on invalid id. Element? getElementById(String id) => querySelector('#$id'); } From 5d87dc8a0638b9f494e7044dc78bd4520341ab6d Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 3 May 2023 12:13:26 -0700 Subject: [PATCH 20/33] added package topics to the pubspec file (#215) * added package topics to the pubspec file * Update pubspec.yaml --- CHANGELOG.md | 4 ++++ pubspec.yaml | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 725d157..7b2ab38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.15.3 + +- Added package topics to the pubspec file. + ## 0.15.2 - Add additional types at the API boundary (in `lib/parser.dart` and others). diff --git a/pubspec.yaml b/pubspec.yaml index eb222a6..f6f56f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,12 @@ name: html -version: 0.15.2 +version: 0.15.3 description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/html +topics: + - html + - web + environment: sdk: '>=2.17.0 <3.0.0' From 593d6f67ef93477312d85c403f5a9b5928467f9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 12:24:21 -0700 Subject: [PATCH 21/33] Bump actions/checkout from 3.5.0 to 3.5.2 (#214) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 568b209..4dda1cd 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 92eacabadf40aa24c8f4289682ef2822c5d7e414 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 17 May 2023 11:10:15 -0700 Subject: [PATCH 22/33] blast_repo fixes (#216) dependabot --- .github/dependabot.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1603cdd..725f03a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,9 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly + labels: + - autosubmit From b3b820bc36ed17673268360d8b569bdc66c22123 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 7 Jun 2023 13:56:38 -0700 Subject: [PATCH 23/33] widen the dependency on 'package:csslib' (#217) * widen the dependency on 'package:csslib' * update CI * Update CHANGELOG.md --- .github/workflows/test-package.yml | 2 +- CHANGELOG.md | 5 +++++ lib/src/css_class_set.dart | 1 - lib/src/tokenizer.dart | 2 -- pubspec.yaml | 8 ++++---- test/query_selector_test.dart | 2 -- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 4dda1cd..96656cb 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -32,7 +32,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [2.17.0, dev] + sdk: [2.19.0, stable, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b2ab38..27ce0c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.15.4 + +- Widen the dependency on `package:csslib`. +- Require Dart `2.19`. + ## 0.15.3 - Added package topics to the pubspec file. diff --git a/lib/src/css_class_set.dart b/lib/src/css_class_set.dart index cebb565..508fd2b 100644 --- a/lib/src/css_class_set.dart +++ b/lib/src/css_class_set.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. // TODO(jmesserly): everything in this file is copied straight from "dart:html". -library html.dom.src; import 'dart:collection'; diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart index 1ab72a9..b1bfa36 100644 --- a/lib/src/tokenizer.dart +++ b/lib/src/tokenizer.dart @@ -1,5 +1,3 @@ -library tokenizer; - import 'dart:collection'; import 'package:html/parser.dart' show HtmlParser; diff --git a/pubspec.yaml b/pubspec.yaml index f6f56f1..e16c0ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: html -version: 0.15.3 +version: 0.15.4 description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/html @@ -8,13 +8,13 @@ topics: - web environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.19.0 <4.0.0' dependencies: - csslib: ^0.17.0 + csslib: '>=0.17.0 <2.0.0' source_span: ^1.8.0 dev_dependencies: - dart_flutter_team_lints: ^0.1.0 + dart_flutter_team_lints: ^1.0.0 path: ^1.8.0 test: ^1.16.0 diff --git a/test/query_selector_test.dart b/test/query_selector_test.dart index 149250f..495b0f1 100644 --- a/test/query_selector_test.dart +++ b/test/query_selector_test.dart @@ -1,5 +1,3 @@ -library query_selector_test; - import 'package:html/dom.dart'; import 'package:test/test.dart'; From 8cb99e4411c44d91a9dae329ba17f6f84c6a67e7 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Sat, 1 Jul 2023 16:04:00 -0700 Subject: [PATCH 24/33] address new analysis issues (#219) --- CHANGELOG.md | 3 +++ pubspec.yaml | 2 +- test/tokenizer_test.dart | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27ce0c0..fa79fbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.15.5-wip + + ## 0.15.4 - Widen the dependency on `package:csslib`. diff --git a/pubspec.yaml b/pubspec.yaml index e16c0ee..e73d479 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: html -version: 0.15.4 +version: 0.15.5-wip description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/html diff --git a/test/tokenizer_test.dart b/test/tokenizer_test.dart index 1281906..74a4a48 100644 --- a/test/tokenizer_test.dart +++ b/test/tokenizer_test.dart @@ -124,8 +124,6 @@ class TokenizerTestParser { addOutputToken(token, ['Character', token.data]); } - void processEOF(StringToken token) {} - void processParseError(StringToken token) { // TODO(jmesserly): when debugging test failures it can be useful to add // logging here like `print('ParseError $token');`. It would be nice to From 4060496b0443451c38f8b789db2e44c0d7966171 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 23:24:12 +0000 Subject: [PATCH 25/33] Bump actions/checkout from 3.5.2 to 3.5.3 (#218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
Release notes

Sourced from actions/checkout's releases.

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

v2.3.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.2&new-version=3.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 96656cb..a123b0e 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From a1b193e95f13c995e7f7200ce0d363de5952e383 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:54:59 +0000 Subject: [PATCH 26/33] Bump actions/checkout from 3.5.3 to 3.6.0 (#225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
Release notes

Sourced from actions/checkout's releases.

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index a123b0e..0294965 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From fb2de8ad1e7f1a8ab54c1f56a53c0f4a1ea4b9b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:49:13 +0000 Subject: [PATCH 27/33] Bump actions/checkout from 3.6.0 to 4.1.0 (#227) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0.
Release notes

Sourced from actions/checkout's releases.

v4.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.0.0...v4.1.0

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.6.0&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 0294965..20a39b5 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 49e2c8e9b3bc9fcf25a8eb290c026d3c94c5d175 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:38:43 +0000 Subject: [PATCH 28/33] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#228) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits
  • 8a4b97e Support renaming the be channel to main. (#102)
  • 0970dcf Bump @​actions/http-client from 2.1.0 to 2.1.1 (#101)
  • e58aeb6 updates for the latest version of extension types (#100)
  • deafe40 Convert to extension types (#99)
  • cdb51ff Bump semver from 6.3.0 to 6.3.1 (#98)
  • e2fce12 update JS interop - remove JS typedef references (#97)
  • 42c988f set up a cron to build the action's javascript (#96)
  • 007c7cb blast_repo fixes (#92)
  • 08de7e0 Remove annotations no longer needed (#91)
  • bd8bef0 Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#89)
  • Additional commits viewable in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.0&new-version=1.5.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 20a39b5..68ac722 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: dev - id: install @@ -35,7 +35,7 @@ jobs: sdk: [2.19.0, stable, dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install From 2630607fc4e6047ac9b609a5861e53789261e0a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:26:21 +0000 Subject: [PATCH 29/33] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#233) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.1&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 68ac722..eb563aa 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev - id: install @@ -35,7 +35,7 @@ jobs: sdk: [2.19.0, stable, dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install From 06bc148600b1d1a70f2256bdf788c213f1f60f55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:31:00 +0000 Subject: [PATCH 30/33] Bump actions/checkout from 4.1.0 to 4.1.1 (#232) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⚠️ **Dependabot is rebasing this PR** ⚠️ Rebasing might not happen immediately, so don't worry if this takes some time. Note: if you make any changes to this PR yourself, they will take precedence over the rebase. --- Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
Release notes

Sourced from actions/checkout's releases.

v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.0...v4.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.0&new-version=4.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index eb563aa..dd52d5d 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev @@ -34,7 +34,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} From aaf7d1a1e1ef87599a64b574109a112b677b9c6a Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 25 Jan 2024 13:52:33 -0800 Subject: [PATCH 31/33] blast_repo fixes (#235) auto-publish, github-actions, no-response --- .github/workflows/no-response.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/publish.yaml | 17 ++++++++++++++ .github/workflows/test-package.yml | 4 ++-- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/no-response.yml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml new file mode 100644 index 0000000..ab1ac49 --- /dev/null +++ b/.github/workflows/no-response.yml @@ -0,0 +1,37 @@ +# A workflow to close issues where the author hasn't responded to a request for +# more information; see https://github.com/actions/stale. + +name: No Response + +# Run as a daily cron. +on: + schedule: + # Every day at 8am + - cron: '0 8 * * *' + +# All permissions not specified are set to 'none'. +permissions: + issues: write + pull-requests: write + +jobs: + no-response: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'dart-lang' }} + steps: + - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e + with: + # Don't automatically mark inactive issues+PRs as stale. + days-before-stale: -1 + # Close needs-info issues and PRs after 14 days of inactivity. + days-before-close: 14 + stale-issue-label: "needs-info" + close-issue-message: > + Without additional information we're not able to resolve this issue. + Feel free to add more info or respond to any questions above and we + can reopen the case. Thanks for your contribution! + stale-pr-label: "needs-info" + close-pr-message: > + Without additional information we're not able to resolve this PR. + Feel free to add more info or respond to any questions above. + Thanks for your contribution! diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..1cb7e9c --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,17 @@ +# A CI configuration to auto-publish pub packages. + +name: Publish + +on: + pull_request: + branches: [ main ] + push: + tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] + +jobs: + publish: + if: ${{ github.repository_owner == 'dart-lang' }} + uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write # Required for authentication using OIDC + pull-requests: write # Required for writing the pull request note diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index dd52d5d..aa34b6b 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: dev - id: install @@ -35,7 +35,7 @@ jobs: sdk: [2.19.0, stable, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: ${{ matrix.sdk }} - id: install From 910f6d703ed0193318fb095be09e8ddf1bec3e05 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 26 Jan 2024 09:15:50 -0800 Subject: [PATCH 32/33] Update lints, require Dart 3.2 (#236) --- .github/workflows/test-package.yml | 2 +- CHANGELOG.md | 1 + lib/dom.dart | 2 +- lib/dom_parsing.dart | 26 +++++++---------- lib/parser.dart | 46 ++++++++++++++---------------- lib/src/constants.dart | 25 ++++++---------- lib/src/css_class_set.dart | 2 +- lib/src/html_input_stream.dart | 16 ++++------- lib/src/query_selector.dart | 33 +++++++++------------ lib/src/token.dart | 8 +++--- lib/src/tokenizer.dart | 2 +- lib/src/treebuilder.dart | 4 +-- pubspec.yaml | 6 ++-- 13 files changed, 75 insertions(+), 98 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index aa34b6b..8e69bc4 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -32,7 +32,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [2.19.0, stable, dev] + sdk: [3.2, stable, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b diff --git a/CHANGELOG.md b/CHANGELOG.md index fa79fbc..c0d6cb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.15.5-wip +- Require Dart `3.2`. ## 0.15.4 diff --git a/lib/dom.dart b/lib/dom.dart index 5b8f8c9..733362a 100644 --- a/lib/dom.dart +++ b/lib/dom.dart @@ -112,7 +112,7 @@ mixin _NonElementParentNode implements _ParentNode { // common methods from these: // http://dom.spec.whatwg.org/#interface-document // http://dom.spec.whatwg.org/#element -abstract class _ElementAndDocument implements _ParentNode { +abstract mixin class _ElementAndDocument implements _ParentNode { // TODO(jmesserly): could be faster, should throw on invalid tag/class names. List getElementsByTagName(String localName) => diff --git a/lib/dom_parsing.dart b/lib/dom_parsing.dart index 35c8dc7..5cf3cab 100644 --- a/lib/dom_parsing.dart +++ b/lib/dom_parsing.dart @@ -12,22 +12,16 @@ export 'html_escape.dart'; /// A simple tree visitor for the DOM nodes. class TreeVisitor { void visit(Node node) { - switch (node.nodeType) { - case Node.ELEMENT_NODE: - return visitElement(node as Element); - case Node.TEXT_NODE: - return visitText(node as Text); - case Node.COMMENT_NODE: - return visitComment(node as Comment); - case Node.DOCUMENT_FRAGMENT_NODE: - return visitDocumentFragment(node as DocumentFragment); - case Node.DOCUMENT_NODE: - return visitDocument(node as Document); - case Node.DOCUMENT_TYPE_NODE: - return visitDocumentType(node as DocumentType); - default: - throw UnsupportedError('DOM node type ${node.nodeType}'); - } + return switch (node.nodeType) { + Node.ELEMENT_NODE => visitElement(node as Element), + Node.TEXT_NODE => visitText(node as Text), + Node.COMMENT_NODE => visitComment(node as Comment), + Node.DOCUMENT_FRAGMENT_NODE => + visitDocumentFragment(node as DocumentFragment), + Node.DOCUMENT_NODE => visitDocument(node as Document), + Node.DOCUMENT_TYPE_NODE => visitDocumentType(node as DocumentType), + _ => throw UnsupportedError('DOM node type ${node.nodeType}') + }; } void visitChildren(Node node) { diff --git a/lib/parser.dart b/lib/parser.dart index 3eb7a97..3c6340a 100644 --- a/lib/parser.dart +++ b/lib/parser.dart @@ -633,7 +633,7 @@ class Phase { } class InitialPhase extends Phase { - InitialPhase(HtmlParser parser) : super(parser); + InitialPhase(super.parser); @override Token? processSpaceCharacters(SpaceCharactersToken token) { @@ -788,7 +788,7 @@ class InitialPhase extends Phase { } class BeforeHtmlPhase extends Phase { - BeforeHtmlPhase(HtmlParser parser) : super(parser); + BeforeHtmlPhase(super.parser); // helper methods void insertHtmlElement() { @@ -849,7 +849,7 @@ class BeforeHtmlPhase extends Phase { } class BeforeHeadPhase extends Phase { - BeforeHeadPhase(HtmlParser parser) : super(parser); + BeforeHeadPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -923,7 +923,7 @@ class BeforeHeadPhase extends Phase { } class InHeadPhase extends Phase { - InHeadPhase(HtmlParser parser) : super(parser); + InHeadPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -1070,7 +1070,7 @@ class InHeadPhase extends Phase { // class InHeadNoScriptPhase extends Phase { class AfterHeadPhase extends Phase { - AfterHeadPhase(HtmlParser parser) : super(parser); + AfterHeadPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -1189,7 +1189,7 @@ class InBodyPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///parsing-main-inbody // the really-really-really-very crazy mode - InBodyPhase(HtmlParser parser) : super(parser); + InBodyPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -2227,7 +2227,7 @@ class InBodyPhase extends Phase { } class TextPhase extends Phase { - TextPhase(HtmlParser parser) : super(parser); + TextPhase(super.parser); // "Tried to process start tag %s in RCDATA/RAWTEXT mode"%token.name @override @@ -2277,7 +2277,7 @@ class TextPhase extends Phase { class InTablePhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///in-table - InTablePhase(HtmlParser parser) : super(parser); + InTablePhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -2507,9 +2507,7 @@ class InTableTextPhase extends Phase { Phase? originalPhase; List characterTokens; - InTableTextPhase(HtmlParser parser) - : characterTokens = [], - super(parser); + InTableTextPhase(super.parser) : characterTokens = []; void flushCharacters() { if (characterTokens.isEmpty) return; @@ -2578,7 +2576,7 @@ class InTableTextPhase extends Phase { class InCaptionPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///in-caption - InCaptionPhase(HtmlParser parser) : super(parser); + InCaptionPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -2700,7 +2698,7 @@ class InCaptionPhase extends Phase { class InColumnGroupPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///in-column - InColumnGroupPhase(HtmlParser parser) : super(parser); + InColumnGroupPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -2788,7 +2786,7 @@ class InColumnGroupPhase extends Phase { class InTableBodyPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///in-table0 - InTableBodyPhase(HtmlParser parser) : super(parser); + InTableBodyPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -2927,7 +2925,7 @@ class InTableBodyPhase extends Phase { class InRowPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///in-row - InRowPhase(HtmlParser parser) : super(parser); + InRowPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3073,7 +3071,7 @@ class InRowPhase extends Phase { class InCellPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///in-cell - InCellPhase(HtmlParser parser) : super(parser); + InCellPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3197,7 +3195,7 @@ class InCellPhase extends Phase { } class InSelectPhase extends Phase { - InSelectPhase(HtmlParser parser) : super(parser); + InSelectPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3353,7 +3351,7 @@ class InSelectPhase extends Phase { } class InSelectInTablePhase extends Phase { - InSelectInTablePhase(HtmlParser parser) : super(parser); + InSelectInTablePhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3479,7 +3477,7 @@ class InForeignContentPhase extends Phase { 'var' ]; - InForeignContentPhase(HtmlParser parser) : super(parser); + InForeignContentPhase(super.parser); void adjustSVGTagNames(StartTagToken token) { final replacements = const { @@ -3609,7 +3607,7 @@ class InForeignContentPhase extends Phase { } class AfterBodyPhase extends Phase { - AfterBodyPhase(HtmlParser parser) : super(parser); + AfterBodyPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3681,7 +3679,7 @@ class AfterBodyPhase extends Phase { class InFramesetPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///in-frameset - InFramesetPhase(HtmlParser parser) : super(parser); + InFramesetPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3774,7 +3772,7 @@ class InFramesetPhase extends Phase { class AfterFramesetPhase extends Phase { // http://www.whatwg.org/specs/web-apps/current-work///after3 - AfterFramesetPhase(HtmlParser parser) : super(parser); + AfterFramesetPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3831,7 +3829,7 @@ class AfterFramesetPhase extends Phase { } class AfterAfterBodyPhase extends Phase { - AfterAfterBodyPhase(HtmlParser parser) : super(parser); + AfterAfterBodyPhase(super.parser); @override Token? processStartTag(StartTagToken token) { @@ -3882,7 +3880,7 @@ class AfterAfterBodyPhase extends Phase { } class AfterAfterFramesetPhase extends Phase { - AfterAfterFramesetPhase(HtmlParser parser) : super(parser); + AfterAfterFramesetPhase(super.parser); @override Token? processStartTag(StartTagToken token) { diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 5c41f81..abd483b 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -246,22 +246,15 @@ class Namespaces { Namespaces._(); static String? getPrefix(String? url) { - switch (url) { - case html: - return 'html'; - case mathml: - return 'math'; - case svg: - return 'svg'; - case xlink: - return 'xlink'; - case xml: - return 'xml'; - case xmlns: - return 'xmlns'; - default: - return null; - } + return switch (url) { + html => 'html', + mathml => 'math', + svg => 'svg', + xlink => 'xlink', + xml => 'xml', + xmlns => 'xmlns', + _ => null + }; } } diff --git a/lib/src/css_class_set.dart b/lib/src/css_class_set.dart index 508fd2b..deca7a5 100644 --- a/lib/src/css_class_set.dart +++ b/lib/src/css_class_set.dart @@ -6,7 +6,7 @@ import 'dart:collection'; -import 'package:html/dom.dart'; +import '../dom.dart'; class ElementCssClassSet extends _CssClassSetImpl { final Element _element; diff --git a/lib/src/html_input_stream.dart b/lib/src/html_input_stream.dart index 1c1bcc8..abae4cf 100644 --- a/lib/src/html_input_stream.dart +++ b/lib/src/html_input_stream.dart @@ -329,16 +329,12 @@ bool _hasUtf8Bom(List bytes, [int offset = 0, int? length]) { /// the codepoints. Supports the major unicode encodings as well as ascii and /// and windows-1252 encodings. List _decodeBytes(String encoding, List bytes) { - switch (encoding) { - case 'ascii': - return ascii.decode(bytes).codeUnits; - - case 'utf-8': + return switch (encoding) { + 'ascii' => ascii.decode(bytes).codeUnits, + 'utf-8' => // NOTE: To match the behavior of the other decode functions, we eat the // UTF-8 BOM here. This is the default behavior of `utf8.decode`. - return utf8.decode(bytes).codeUnits; - - default: - throw ArgumentError('Encoding $encoding not supported'); - } + utf8.decode(bytes).codeUnits, + _ => throw ArgumentError('Encoding $encoding not supported') + }; } diff --git a/lib/src/query_selector.dart b/lib/src/query_selector.dart index c45d11c..96fe4d2 100644 --- a/lib/src/query_selector.dart +++ b/lib/src/query_selector.dart @@ -3,8 +3,9 @@ library html.src.query; import 'package:csslib/parser.dart'; import 'package:csslib/visitor.dart'; -import 'package:html/dom.dart'; -import 'package:html/src/constants.dart' show isWhitespaceCC; + +import '../dom.dart'; +import 'constants.dart' show isWhitespaceCC; bool matches(Element node, String selector) => SelectorEvaluator().matches(node, _parseSelectorList(selector)); @@ -284,22 +285,16 @@ class SelectorEvaluator extends Visitor { if (node.operatorKind == TokenKind.NO_MATCH) return true; final select = '${node.value}'; - switch (node.operatorKind) { - case TokenKind.EQUALS: - return value == select; - case TokenKind.INCLUDES: - return value.split(' ').any((v) => v.isNotEmpty && v == select); - case TokenKind.DASH_MATCH: - return value.startsWith(select) && - (value.length == select.length || value[select.length] == '-'); - case TokenKind.PREFIX_MATCH: - return value.startsWith(select); - case TokenKind.SUFFIX_MATCH: - return value.endsWith(select); - case TokenKind.SUBSTRING_MATCH: - return value.contains(select); - default: - throw _unsupported(node); - } + return switch (node.operatorKind) { + TokenKind.EQUALS => value == select, + TokenKind.INCLUDES => + value.split(' ').any((v) => v.isNotEmpty && v == select), + TokenKind.DASH_MATCH => value.startsWith(select) && + (value.length == select.length || value[select.length] == '-'), + TokenKind.PREFIX_MATCH => value.startsWith(select), + TokenKind.SUFFIX_MATCH => value.endsWith(select), + TokenKind.SUBSTRING_MATCH => value.contains(select), + _ => throw _unsupported(node) + }; } } diff --git a/lib/src/token.dart b/lib/src/token.dart index 7a4e743..bbcec26 100644 --- a/lib/src/token.dart +++ b/lib/src/token.dart @@ -77,14 +77,14 @@ class ParseErrorToken extends StringToken { /// Extra information that goes along with the error message. Map? messageParams; - ParseErrorToken(String data, {this.messageParams}) : super(data); + ParseErrorToken(String super.data, {this.messageParams}); @override int get kind => TokenKind.parseError; } class CharactersToken extends StringToken { - CharactersToken([String? data]) : super(data); + CharactersToken([super.data]); @override int get kind => TokenKind.characters; @@ -98,14 +98,14 @@ class CharactersToken extends StringToken { } class SpaceCharactersToken extends StringToken { - SpaceCharactersToken([String? data]) : super(data); + SpaceCharactersToken([super.data]); @override int get kind => TokenKind.spaceCharacters; } class CommentToken extends StringToken { - CommentToken([String? data]) : super(data); + CommentToken([super.data]); @override int get kind => TokenKind.comment; diff --git a/lib/src/tokenizer.dart b/lib/src/tokenizer.dart index b1bfa36..3bed0b0 100644 --- a/lib/src/tokenizer.dart +++ b/lib/src/tokenizer.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:html/parser.dart' show HtmlParser; +import '../parser.dart' show HtmlParser; import 'constants.dart'; import 'html_input_stream.dart'; diff --git a/lib/src/treebuilder.dart b/lib/src/treebuilder.dart index 3e39700..a7a8e82 100644 --- a/lib/src/treebuilder.dart +++ b/lib/src/treebuilder.dart @@ -3,10 +3,10 @@ library treebuilder; import 'dart:collection'; -import 'package:html/dom.dart'; -import 'package:html/parser.dart' show getElementNameTuple; import 'package:source_span/source_span.dart'; +import '../dom.dart'; +import '../parser.dart' show getElementNameTuple; import 'constants.dart'; import 'list_proxy.dart'; import 'token.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index e73d479..5824b76 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,13 +8,13 @@ topics: - web environment: - sdk: '>=2.19.0 <4.0.0' + sdk: ^3.2.0 dependencies: - csslib: '>=0.17.0 <2.0.0' + csslib: ^1.0.0 source_span: ^1.8.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 path: ^1.8.0 test: ^1.16.0 From 327e37a6a4dd46599737ee982f280d73a8f646f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:23:20 +0000 Subject: [PATCH 33/33] Bump dart-lang/setup-dart from 1.6.1 to 1.6.2 (#237) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.1 to 1.6.2.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.2

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.1&new-version=1.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 8e69bc4..0a520fb 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: dev - id: install @@ -35,7 +35,7 @@ jobs: sdk: [3.2, stable, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install