Skip to content

[css-page3] [cssom] Descriptors and properties #9685

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

Closed
AlaskanEmily opened this issue Dec 8, 2023 · 3 comments
Closed

[css-page3] [cssom] Descriptors and properties #9685

AlaskanEmily opened this issue Dec 8, 2023 · 3 comments
Labels
css-page-3 Current Work cssom-1 Current Work

Comments

@AlaskanEmily
Copy link

Currently CSSOM specifies how properties are exposed on on CSSStyleDeclarations. Right now, Chrome and WebKit include a size property, reflecting the size "property" as here: https://drafts.csswg.org/css-page/#page-size-prop which can also be set on the CSSStyleDeclarations that is the style property of a CSSPageRule. However size isn't really a property in this sense, it behaves as a descriptor and is not valid as a property on the style of an element. Firefox does not allow it to be set on CSSStyleDeclarations, and it is only settable on the style of a CSSPageRule using setProperty.
It makes some sense that size could be settable on the style value of a CSSPageRule, so perhaps the style property of CSSPageRule should be a new interface that inherits from CSSStyleDeclarations but adds size and possibly page-orientation.

@emilio emilio added css-page-3 Current Work cssom-1 Current Work Agenda+ labels Dec 8, 2023
@dholbert
Copy link
Member

dholbert commented Dec 8, 2023

To make this concrete, here's a testcase:
https://bug1867106.bmoattachments.org/attachment.cgi?id=9365919

The relevant style rule there is @page { size: 3px }, and if you view the output in web console, the last bit of logged output tries to get the value by logging this expression:

document.styleSheets[0].rules[3].style.size

In Firefox, this expression evaluates to undefined for reasons that Emily discussed above, which we think is correct per current spec, since .size isn't available on the interface. But Chromium/WebKit have it there anyway, and they log 3px.

In Firefox, the following longer version with getPropertyValue does evaluate to the actual 3px value as-expected:

document.styleSheets[0].rules[3].style.getPropertyValue("size")

so I think that's what web developers are currently supposed to do, but the fact that .size works in other browsers (and feels less-clumsy) makes it tempting to make that officially work for this situation.

@cdoublev
Copy link
Collaborator

cdoublev commented Dec 8, 2023

I think this has been resolved in #5649:

So, here's a proposal. [...] CSSPageProperties for @page rules, with only the page descriptors

Is there any reason why we can't go for [...] CSSPageDescriptors [...] ?

RESOLVED: Having different interfaces for declarations blocks that expose a different set of descriptors/properties
RESOLVED: Go with emilio naming and Sam's amendment

In Chrome, fontFaceRule.style.getPropertyValue('color') currently returns green after fontFaceRule.style.setProperty('color', 'green'), which seems undesirable.

Similarly, I think keyframeRule.style.setProperty('animation-duration', '1s') should do nothing, as in Chrome but not Firefox, like tryRule.style.setProperty('color', 'green') (not supported by any browser).

@emilio
Copy link
Collaborator

emilio commented Dec 8, 2023

Yeah, dupe of #5649. Self-reminder for doing the spec changes.

@emilio emilio closed this as completed Dec 8, 2023
@svgeesus svgeesus removed the Agenda+ label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-page-3 Current Work cssom-1 Current Work
Projects
None yet
Development

No branches or pull requests

5 participants