Skip to content

Commit

Permalink
Stricter match for arbitrary properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Aug 27, 2022
1 parent aa4e824 commit 337f286
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ The implementation would work most of the time, but some shortcuts have been mad
- `backgroundImage`, `backgroundPosition` and `fontFamily` are not supported
- For prefix with collision (divide, border, bg, stroke, text, decoration, outline, ring, ring-offset), if the value doesn't match a CSS color (hex, rgb\[a], hsl\[a]) it's interpreted as the "size" version. Using data types is not supported
- Underscore are always mapped to space
- Values with quotes are not possible (by design for fast scanning)
- The theme function is not supported

[Arbitrary properties](https://tailwindcss.com/docs/adding-custom-styles#arbitrary-properties) can be used to bypass the rare edge cases.
[Arbitrary properties](https://tailwindcss.com/docs/adding-custom-styles#arbitrary-properties) can be used to bypass some edge cases.

### Extending theme

Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const applyRE = /[{\s]@apply ([^;}\n]+)([;}\n])/g;
const screenRE = /screen\(([a-z-]+)\)/g;
const themeRE = /theme\(([^)]+)\)/g;
const validSelectorRE = /^[a-z0-9.:/_[\]!#&()-]+$/;
const arbitraryPropertyRE = /^\[[^[\]:]+:[^[\]:]+]$/;

type Match = {
token: string;
Expand Down Expand Up @@ -114,7 +115,7 @@ export const initDownwindWithConfig = ({

const extractVariant = () => {
if (tokenWithoutVariants.startsWith("[")) {
if (tokenWithoutVariants.endsWith("]")) {
if (arbitraryPropertyRE.test(tokenWithoutVariants)) {
isArbitraryProperty = true;
return "NO_VARIANT" as const;
}
Expand Down

0 comments on commit 337f286

Please sign in to comment.