-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
IS_NON_DIMENSIONAL has false positives and false negatives #2607
Labels
Comments
kripod
added a commit
to kripod/preact
that referenced
this issue
Jul 8, 2020
This was referenced Jul 8, 2020
developit
added
known issue
The issue is known and may be left as-is.
discussion
labels
Jul 14, 2020
4 tasks
marvinhagemeister
pushed a commit
that referenced
this issue
Jul 16, 2020
JoviDeCroock
pushed a commit
that referenced
this issue
Aug 16, 2020
Closing, we merged this in the v11 release line 🎉 |
Closed
Was the change reverted at some point? Line 3 in 15913ad
|
@fabiospampinato Merged into v11, the |
Oh I see, thanks for the clarification 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recently, I wrote some tests for a regular expression with functionality similar to
IS_NON_DIMENSIONAL
. Out of curiosity, I ran the same tests against Preact's implementation and found the following results:False positives
When given a number, it should be postfixed with 'px' for the CSS properties below:
grid-auto-columns
grid-auto-rows
grid-template-columns
grid-template-rows
The properties above don't accept unitless values. However,
IS_NON_DIMENSIONAL
matches them, so they're not postfixed with 'px' when given a number.False negatives
When given a number, it should not be postfixed with 'px' for the CSS properties below:
flex-grow
flex-shrink
font-size-adjust
font-weight
line-height
line-clamp
-webkit-line-clamp
animation
border-image
border-image-outset
border-image-slice
border-image-width
shape-image-threshold
scale
mask-border
mask-border-outset
mask-border-slice
mask-border-width
max-lines
tab-size
columns
column-count
initial-letter
The properties above accept unitless values. However,
IS_NON_DIMENSIONAL
doesn't match them, so they're mistakenly postfixed with 'px' when given a number.Details of the test
A potential fix
The implementation of otion passes all the tests, while also checking strings in a more performant manner (matching only from the start instead of at any position):
Unlike Preact's 67-byte solution, however, it weighs in at 115 bytes, adding 48 bytes to the bundle size.
The text was updated successfully, but these errors were encountered: