Repository navigation
css: require at least one component in the background, transition, animation, mask, flex and flex-flow shorthands #46816
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,6 +50,7 @@ impl Transition { | ||||||||||||||||
| let mut delay: Option<Time> = None; | |||||||||||||||||
| let mut timing_function: Option<EasingFunction> = None; | |||||||||||||||||
|
|
|||||||||||||||||
| let start = parser.position(); | |||||||||||||||||
| loop { | |||||||||||||||||
| if duration.is_none() { | |||||||||||||||||
| if let Ok(value) = parser.try_parse(Time::parse) { | |||||||||||||||||
|
|
@@ -81,6 +82,7 @@ impl Transition { | ||||||||||||||||
|
|
|||||||||||||||||
| break; | |||||||||||||||||
| } | |||||||||||||||||
| parser.expect_advanced_from(start)?; | |||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 (optional) Sites whose stylesheets have a trailing comma in an animation list lose the effect in built output after upgrading; on the base branch it ran. src/css/properties/transition.rs:85 and the matching checks in animation.rs:123, masking.rs:204 and background.rs:111 reject the empty list item, so Why this was flaggedIf any application stylesheet contains a trailing or doubled comma in Verification: Acknowledged in diff: the PR description's "Downsides" and the new test block pin it. Now
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the first Downsides bullet of the PR body. I did not change the code, for these reasons. The repair is a side effect of the defect, and it helps only some inputs. Release builds of main and of this PR, with Chrome 153:
A maintainer decides between the output of 1.4.x and the strict output. The PR body says so. |
|||||||||||||||||
|
|
|||||||||||||||||
| Ok(Self { | |||||||||||||||||
| property: property.unwrap_or(PropertyId::All), | |||||||||||||||||
|
|
|||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 (optional) Pre-existing, widened by this change: a stylesheet with
.a{animation:none}.b{color:red}.a{animation:}now loses theanimation:nonereset that the base kept. The empty value now becomes an unparsed declaration, andStyleRule::is_duplicate(src/css/rules/style.rs:480) compares onlyproperty_id(), so the earlier.arule is removed and the browser drops the unparsed.a{animation:}. Fix: make the duplicate-rule check not treat an unparsed declaration as equal to a parsed one of the same name, so every shorthand this PR turns into unparsed text keeps the earlier same-selector rule; the PR marks this with acssTestTodorather than fixing it. [also at: src/css/properties/flex.rs:163 - Minified output drops a validflexvalue entirely when a later same-selector rule has an emptyflex:and a different rule sits between them; main keptflex:1.; src/css/properties/masking.rs:204 - Pages that resetmask,background,transitionorflex-flowin an earlier same-selector rule lose the reset in minified output when a later rule has the empty shorthand; main preserved it. src/css/properties/masking.rs:204 (and background.rs:111, transition.rs:85, flex.rs:85) makes the empty…]Why this was flagged
Input
.a{animation:none}.b{color:red}.a{animation:}throughbun buildor the dev server. With the diff,Animation::parsefails at src/css/properties/animation.rs:123 and the declaration is stored as an unparsed property whoseproperty_id()is stillAnimation. During minify,StyleRule::is_duplicateat src/css/rules/style.rs:465-495 compares rule declarations byproperty_id()only, so the first.arule is judged a duplicate of the last and removed. Output is.b{color:red}.a{animation:}; a browser drops the empty declaration, so noanimation:nonereaches the page. On the base branch the empty value parsed tonone, so the output.b{color:red}.a{animation:none}still applied the reset. The same removal now happens forbackground,transition,mask,flexandflex-flowrules in that shape; the PR description and thecssTestTodoat test/js/bun/css/css.test.ts:8058 note the duplicate check but leave it unfixed.Verification: The failed typed parse becomes
Property::Unparsedcarrying the original id (src/css/properties/properties_generated.rs:3888-3889). src/css/rules/style.rs:466-480is_duplicatecompares onlya.property_id() != b.property_id(), so a parsedanimation:noneand an unparsedanimation:compare equal; src/css/rules/mod.rs:850-859 then drops the earlier.arule.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed. It is the second Downsides bullet of the PR body, and the
cssTestTodorow holds the expected output. I did not changeis_duplicatein this PR, for these reasons..a{background:red}.b{color:red}.a{background:}prints.b{color:red}.a{background:0 0}on main and.b{color:red}.a{background:}with this PR. A browser computes a transparent background for both. The output of main is right only when the value that it made from nothing equals the earlier value, as withanimation:none. For.a{flex:2}.b{color:red}.a{flex:}main printsflex:1, which is also not theflex:2of the source..a{color:red}.b{top:0}.a{color:foo(1)}prints.b{top:0}.a{color:foo(1)}..a{font:12px a}.b{color:red}.a{font:}prints.b{color:red}.a{font:}..a{color:red}before a later.a{color:var(--x)}. That later rule is valid and does override the first, so sheets with no defect grow. It also does not cover an earlier unparsed value:.a{background:var(--x)}.b{color:red}.a{background:}still prints.b{color:red}.a{background:}.PropertyIdequality and importance in duplicate-rule detection #33684, css: fold relative colors on the scale of their function, and keep them as written when the fold is not exact #45362 and css: parse the*propertyhack as a declaration #46751 each editis_duplicate.