Skip to content

Commit

Permalink
Fix issue with target.matches in CSS parsing (#157)
Browse files Browse the repository at this point in the history
Skip exceptions with target.matches on unsupported queries.

This skips attempts to check whether unsupported queries match such as @layer or @media.
---------

Co-authored-by: Callie Riggins <[email protected]>
  • Loading branch information
calinoracation and Callie Riggins authored Sep 19, 2023
1 parent 031f127 commit 456e9cd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/scroll-timeline-css-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,18 @@ export class StyleParser {
// rule that matches, instead take the one with the most specifity among those that match
for (let i = this.cssRulesWithTimelineName.length - 1; i >= 0; i--) {
const current = this.cssRulesWithTimelineName[i];
if (target.matches(current.selector)) {
if (!current['animation-name'] || current['animation-name'] == animationName) {
return {
'animation-timeline': current['animation-timeline'],
'animation-range': current['animation-range']
try {
if (target.matches(current.selector)) {
if (!current['animation-name'] || current['animation-name'] == animationName) {
return {
'animation-timeline': current['animation-timeline'],
'animation-range': current['animation-range']
}
}
}
}
} catch {
// TODO: handle nested at-rules
}
}

return null;
Expand Down

0 comments on commit 456e9cd

Please sign in to comment.