Skip to content

Property reordering during minification causes certain settings to be ignored #1207

@samizdatco

Description

@samizdatco

Lightning's property-reordering behavior during minification can result in shorthand properties being moved after a lower-level setting, causing it to be reset to its default value.

In particular, I've encountered it in this situation (playground):

Original CSS

p{
  font: 12px serif;
  font-variant-numeric: oldstyle-nums;
}

Minified

p{font-variant-numeric:oldstyle-nums;font:12px serif}

The font shorthand property resets all the font-variant-* settings to their default, despite the clear intent of the original CSS to refine font settings after selecting the family and size.

Workaround

Adding !important to the font-variant-numeric property seems to have the side effect of reordering it to the end of the block rather than the beginning (playground), which solves the immediate rule-override issue but has the knock-on effect of interfering with the normal cascade for the variant setting. So it's not a fully satisfactory ‘solution’ to the problem.

Proposed Solutions

Reordering should either be something that can be optionally disabled, or the reordering logic should consider which shorthand properties override others and preserve their relative ordering in those cases. Perhaps this latter logic already exists and the font-variant-numeric edge case simply needs to be incorporated?

See Also

#231
#276

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions