Skip to content
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

Fix set property invalid description of priority parameter #38766

Merged
merged 5 commits into from
Mar 22, 2025

Conversation

OlaviSau
Copy link
Contributor

Description

This change corrects the parameter description for CSSStyleDeclaration setProperty method.

Motivation

These changes reflect the full list of accepted values and more accurately describe what happens when an invalid value is passed.

Additional details

Related issues and pull requests

  • I am not sure if there are related issues.

@OlaviSau OlaviSau requested a review from a team as a code owner March 22, 2025 10:04
@OlaviSau OlaviSau requested review from sideshowbarker and removed request for a team March 22, 2025 10:04
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Mar 22, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented Mar 22, 2025

Preview URLs

(comment last updated: 2025-03-22 18:15:29)

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks

@Josh-Cena Josh-Cena merged commit 20a1c2b into mdn:main Mar 22, 2025
8 checks passed
@OlaviSau
Copy link
Contributor Author

OlaviSau commented Mar 25, 2025

@Josh-Cena If the value is empty and the priority is invalid, no change will be applied even if the value is empty, so the changed description is invalid. Verified on chrome / firefox.
Thus "unless value is empty, in which case the property is removed regardless of the priority value" is not valid.

@Josh-Cena
Copy link
Member

@OlaviSau It works on Firefox. To try this, open the live example on this page. Change the stylesheet line to const stylesheet = document.styleSheets[2]; (an annoying bug: mdn/yari#12809) and change the setRandomBorder function to:

function setRandomBorder() {
  boxParaRule.style.setProperty("border", "", "foo");
}

And press the "border" button. You will see that the border disappears.

The algorithm in the spec: https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty also says if value is empty then priority is not validated at all.

That it does not work in Chrome or Safari may be a bug to be reported to these browsers, but Firefox is the only compliant browser for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants