Skip to content

[cssom] Doubt about resolved value of shorthands #1041

@mrego

Description

@mrego

Spec text: https://drafts.csswg.org/cssom/#resolved-value

The resolved value for a given longhand property can be determined as follows:

  • A bunch of properties defining it.
  • A resolved value special case property defined in another specification.
    As defined in the relevant specification.
  • Any other property.
    The resolved value is the computed value.

The spec talks about longhand so I'm not sure what's the expected behavior for shorthands.

I've tried the following example for the flex shorthand:

  <div style="display: flexbox;">
    <div id="flexitem" style="flex: 1;">item</div>
  </div>
  <script>
    console.log("flex: " + window.getComputedStyle(document.querySelector("#flexitem")).flex);
  </script>

The output in Chrome, Safari and Edge is:

  flex: 1 1 0%

However in Firefox it's:

  flex: 

In a different issue @upsuper commented:

IIRC in general we don't serialize new shorthands in computed style, only longhands are serialized there. There are several shorthands get serialized in computed style just for backward compatibility.

What's the expected behavior?
Should the spec be updated to be clearer about the resolved value of shorthands?

Thanks! 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions