Skip to content

[css-mixins-1] Flesh out CSSFunctionRule #11832

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

Merged
merged 4 commits into from
Mar 10, 2025

Conversation

andruud
Copy link
Member

@andruud andruud commented Mar 5, 2025

CSSFunctionRule has so far ignored the existence of a prelude in the @function rule. This adds CSSOM support for the function name, return type, and parameters.

CSSFunctionRule has so far ignored the existence of a prelude
in the @function rule. This adds CSSOM support for the function
name, return type, and parameters.
@andruud andruud requested a review from tabatkins March 5, 2025 14:54
@tabatkins
Copy link
Member

I presume we'd want to represent the body as well, right? As a .style/.childRules pair, like style rules do?

(The rest looks good on a quick skim.)

@andruud
Copy link
Member Author

andruud commented Mar 7, 2025

I presume we'd want to represent the body as well, right? As a .style/.childRules pair, like style rules do?

It's there, it's just not easily visible: we get childRules by inheriting from CSSGroupingRule. (Should probably be made more easily visible.)

.style

There is intentionally no style attribute on CSSFunctionRule. The "leading" block of declarations (if any) is just wrapped in a CSSFunctionDeclarations rule and put in childRules. This is consistent with other grouping rules affected by nested declarations, i.e. nested grouping rules, and even @scope top-level as of #10389. I think it's more consistent this way, vs. treating the leading block as special.

CSSFunctionDeclarations has a style attribute, though. :-)

(The rest looks good on a quick skim.)

Like briefly discussed elsewhere, should we be using a CSSOMString? return value for attributes that possibly have no value? (And return null instead of "" when there is no value?)

@tabatkins
Copy link
Member

Like briefly discussed elsewhere, should we be using a CSSOMString? return value for attributes that possibly have no value? (And return null instead of "" when there is no value?)

Yup, an empty default and no default are definitely distinct values, and need to be represented differently in the OM. I've gone ahead and made the default CSSOMString? to accommodate.

@tabatkins tabatkins merged commit 61d88e2 into w3c:main Mar 10, 2025
1 check passed
@andruud andruud deleted the more_function_cssom branch March 11, 2025 11:28
@andruud
Copy link
Member Author

andruud commented Mar 11, 2025

Like briefly discussed elsewhere, should we be using a CSSOMString? return value for attributes that possibly have no value? (And return null instead of "" when there is no value?)

Yup, an empty default and no default are definitely distinct values, and need to be represented differently in the OM. I've gone ahead and made the default CSSOMString? to accommodate.

Right, looks like we already did represent it differently: no default = no entry in the dictionary; empty default = empty CSSOMString.

I take it we then prefer an explicit null entry if there is no default?

@tabatkins
Copy link
Member

no default = no entry in the dictionary; empty default = empty CSSOMString.

Yeah, much better to have a consistent object shape with a null-valued property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants