critters: rules skipped due to selector errors: legend+* -> Cannot read property 'type' of undefined
Bug description:
When building angular using the production
configuration, the step Generating index html...
produces following warning:
1 rules skipped due to selector errors: legend+* -> Cannot read property 'type' of undefined
See this screenshot:
Reproduction Steps
In Terminal using Angular CLI:
ng new testproject --style scss
cd testproject
ng add @ng-bootstrap/ng-bootstrap
npm run build
Versions
Critters: 0.0.16
Angular: 13.3.0 - 13.3.2
ng-bootstrap: 12.0.2
Bootstrap: 5.1.3
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 18
- Comments: 34 (4 by maintainers)
Commits related to this issue
- Failing test case to reproduce #103 This only happen with css-select@4.3.0 — committed to PowerKiKi/critters by PowerKiKi 2 years ago
- Pin `css-select` to latest compatible version The proper long-term solution is discussed in https://github.com/GoogleChromeLabs/critters/issues/103#issuecomment-1208236366 but until then we should at... — committed to PowerKiKi/critters by PowerKiKi 2 years ago
- Pin `css-select` to latest compatible version The proper, long-term solution is discussed in https://github.com/GoogleChromeLabs/critters/issues/103#issuecomment-1208236366 but until then we should a... — committed to PowerKiKi/critters by PowerKiKi 2 years ago
- cssライブラリ追加、その微調整 npm install --save @fortawesome/fontawesome-free ng add ngx-bootstrap npm remove bootstrap npm install bootstrap@~5.1 package.jsonに以下を追記 "overrides": { "autoprefixer": "10.4.5"... — committed to UnlimitedFairytales/AngularTemplate by takemori-kondo a year ago
Getting the same (I think) with Tailwind typography plugin:
The only selectors, that error, seem to be with
+ *
in them.I’ve had a closer look at this bug, and I now think it comes from an incompatibility between
parse5
which is used to parse HTML andcss-select
that is used to query CSS selectors. The document model is entirely different, and thuscss-select
try to access properties that never exist (node.prev
).It seems the most obvious solution would be to replace
parse5
withhtmlparser2
, because it is part of the same ecosystem ascss-select
. However that also means that the DOM mutation must be ported to something else, most likely todomutils
, and the same goes for the DOM serialization where the obvious choice would bedom-serializer
.All of that is a rather significant amount of work, and quite risky. It would probably be best if someone who know this codebase well would do it (instead of me)…
The warning text
My codes
We did raise this issue with the Chrome team, my understanding is that @janicklas-ralph will look into this and several other issues in Q1.
I have a similar issue in Angular 17.1.0: ng build
▲ [WARNING] 2 rules skipped due to selector errors: .form-floating>~label -> Did not expect successive traversals. .form-floating>~label -> Did not expect successive traversals.
This problem appeared when I upgraded Angular v15 -> v16 (critters v0.0.16 -> v0.0.20)
No me funciono 😕
This is correct. And because of that I think this issue should have a higher priority. At the very least Angular team should pin an exact version of package when it still worked.
@PowerKiKi, I did bring this up among other issues with Critters. However, this will require some further discussions with the Chrome team
@PowerKiKi, thanks for bring this up. I am not sure what was the reason why
parse5
was used instead ofhtmlparser2
.Although
css-select
can support a custom adapter forparse5
, see: https://github.com/fb55/css-select#options It does sound reasonable to me to usehtmlparser2
directly as this would also avoid having to maintain a custom parse5 adapter like https://github.com/Polymer/css-select-parse5-adapter.Maybe @janicklas-ralph can pitch in?
I am seeing the exact same error message and have the same versions as above. This was not happening until I just upgraded my project to the latest versions of these packages.