Repository navigation
fix: stop relying on package:html internals for selector matching - #1519
Closed
Eder-Queiroz wants to merge 1 commit into
Closed
Eder-Queiroz wants to merge 1 commit into
Eder-Queiroz wants to merge 1 commit into
Conversation
StyledElement.matches() called package:html/src/query_selector.dart's matches() via an implementation_imports-ignored import. That file is under html's private lib/src/ and isn't covered by its semver guarantees; its top-level matches() was removed as "unused" internal code in html 0.15.7, breaking compilation for anyone pulling a fresh `html` resolution (dart-lang/tools#2574). Vendor the small CSS selector evaluator into lib/src/css_selector_matcher.dart, built only on package:html's public Element/Node API and package:csslib's public selector AST, so flutter_html no longer depends on html's internals.
Author
|
Closing in favor of #1516, which fixes the same issue with a much smaller diff by calling Our approach here removes the last dependency on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StyledElement.matches()callspackage:html/src/query_selector.dart'smatches()via animplementation_imports-ignored import (the code even has aTODOacknowledging this is risky). That file lives under html's privatelib/src/and isn't covered by semver guarantees — its top-levelmatches()function was removed as "unused" internal code inhtml 0.15.7(dart-lang/tools#2518), which breaks compilation offlutter_html 3.0.0for anyone who resolves a freshhtmlversion (no lockfile, orflutter pub upgrade):This is already affecting users — see dart-lang/tools#2574.
Fix
Vendors the small CSS selector evaluator from
package:html's internalquery_selector.dartinto a newlib/src/css_selector_matcher.dart, built only onpackage:html's publicElement/NodeAPI andpackage:csslib's public selector AST (SelectorGroup,Visitor, etc.).StyledElement.matches()now calls this local matcher instead of reaching intohtml's internals, so a future breaking change to html's private files can no longer breakflutter_html.Behavior is unchanged — the evaluator logic (combinators, pseudo-classes, attribute selectors,
nth-child, etc.) is copied as-is from the html package's implementation (MIT-licensed, attribution comment included in the new file).Test plan
flutter analyze— no issuesflutter test— all 233 existing tests pass (including selector-dependent tests like tag/class matching fortagsList)flutter pub getnow resolveshtml 0.15.7cleanly and the package compiles