Skip to content

Shorthand properties don't merge with equivalent non-shorthand properties as expected. #19

Description

@tkaemming

Shorthand properties (e.g. padding, margin, font, etc.) mixed with individual property declarations don't merge as expected, and the resulting property list can violate specificity rules.

For instance, this example:

h1 { padding: 0 10px; }
h1#id { padding-top: 10px; }

should combine to either of these equivalent forms:

padding: 10px 10px 0 10px

or:

padding-top: 10px;
padding-right: 10px;
padding-bottom: 0;
padding-left: 10px;

… but right now, that property list ends up merging and resulting in this property list:

padding: 0 10px;
padding-top: 10px;

or, this property list — since the output order is non-deterministic:

padding-top: 10px;
padding: 0 10px;

These two different forms have two different results, with their computed results being:

padding-bottom: 0px;
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;

and:

padding-bottom: 0px;
padding-left: 10px;
padding-right: 10px;
padding-top: 0px;

This behavior is explained under "Tricky edge cases" on the MDN documentation.

A good first step would probably be to expand shorthand properties to individual properties upon parsing (ensuring shorthand and individual properties are never merged.) Later, properties could be "compressed" back into shorthand when possible to conserve bytes.

Metadata

Metadata

Assignees

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