Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3: Allow hyphen character in regex pattern to use support queries as is #13605

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brandonmcconnell
Copy link
Contributor

@brandonmcconnell brandonmcconnell commented Apr 28, 2024

This is the v3 equivalent of PR #13596

Matching for the hyphen character in the existing regex to use support queries as-is

Resolves #13594

Tests (w/ updated):

  • supports-[display:grid]:grid
  • supports-[transform-origin:5%_5%]:underline
  • supports-[not(foo:bar)]:underline
  • supports-[(foo:bar)or(bar:baz)]:underline
  • supports-[(foo:bar)and(bar:baz)]:underline
  • supports-[(foo:bar)_and_(bar:baz)]:grid
  • supports-[(foo:bar)_and_(bar:baz)_or(baz:qux)]:grid
  • supports-[container-type]:underline
  • supports-grid:underline
  • supports-[--test]:flex
  • supports-[selector(A_>_B)]:underline
  • supports-[font-format(opentype)]:grid
  • supports-[font-tech(color-COLRv1)]:flex

Comment on lines -412 to +413
let check = normalize(value)
let isRaw = /^\w*\s*\(/.test(check)
let check = value.startsWith('--') ? value : normalize(value)
let isRaw = /^[\w-]*\s*\(/.test(check)
Copy link
Contributor Author

@brandonmcconnell brandonmcconnell Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 changes made

  • added a value.startsWith('--') pre-normalization check that operates in line with Remove automatic var(…) injection #13537 to prevent automatic var(…) injection when checking support for custom properties

    example: supports-[--test]:flex with vs. without with the value.startsWith('--') to prevent normalizing:

    • @supports var(--test) (before, without check)
    • @supports (--test: var(--tw)) (after, with check)
  • added hyphen-support for regex pattern matching raw supports queries

@brandonmcconnell brandonmcconnell changed the title (v3): Allow hyphen character in regex pattern to use support queries as is v3: Allow hyphen character in regex pattern to use support queries as is Apr 29, 2024
@brandonmcconnell
Copy link
Contributor Author

brandonmcconnell commented Aug 8, 2024

@adamwathan @RobinMalfait Just a reminder that this PR is ready to merge (after syncing).

Its v4 equivalent was merged via #13596.

This PR resolves issue #13594 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant