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

Generate partial IDL fragments for CSS properties for WPT? #51

Closed
gsnedders opened this issue Aug 9, 2020 · 5 comments
Closed

Generate partial IDL fragments for CSS properties for WPT? #51

gsnedders opened this issue Aug 9, 2020 · 5 comments

Comments

@gsnedders
Copy link

CSSOM defines up to three partial interfaces that are created for each supported property:

partial interface CSSStyleDeclaration {
  [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _camel_cased_attribute;
};
partial interface CSSStyleDeclaration {
  [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _webkit_cased_attribute;
};
partial interface CSSStyleDeclaration {
  [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _dashed_attribute;
};

It would be nice to have these tested in WPT, whether Reffy itself generates these or whether they're generated merely for the WPT export.

See also speced/bikeshed#549 for a Bikeshed feature request to add generation of these to Bikeshed, and w3c/csswg-drafts#5412 for potential pitfalls here (though as far as I'm aware no such property is currently defined)

@foolip
Copy link
Member

foolip commented Aug 20, 2020

I've previously experimented in that direction in foolip/wpt@e2c50fb and you have filed web-platform-tests/wpt#9113 where there's some discussion.

I did write code at one point to generate the Web IDL, which I can't find, but it's easy to do.

However, since there's more that can be checked in JS for each property than these attributes, like CSS.support and behavior of document.body.style.stuff, I wonder if it doesn't make the most sense to generate those tests in one place and not bother with the minimal help we'd get from using idlharness.js.

@gsnedders
Copy link
Author

gsnedders commented Aug 20, 2020

However, since there's more that can be checked in JS for each property than these attributes, like CSS.support and behavior of document.body.style.stuff, I wonder if it doesn't make the most sense to generate those tests in one place and not bother with the minimal help we'd get from using idlharness.js.

I think we want both?

@foolip
Copy link
Member

foolip commented Aug 21, 2020

Yes, and because we want both having the generated IDL isn't going to be all that useful, we can check the small number of things they would check together with the other tests, so that shallow tests for a property are in one place, with one naming convention. I think that'll be nicer to deal with when adding support and updating test expectations, at least.

@tidoust
Copy link
Member

tidoust commented Mar 10, 2021

Summary of the discussion in #111 on this topic: generating the IDL is not that useful but having the IDL attribute names that each property generates is. Goal is thus to add a styleDeclaration key to property descriptions in CSS extracts that is an array with IDL attribute names. For instance:

 {
   "properties": {
     "align-content": {
       "styleDeclaration": ["align-content", "alignContent"]
     }
   }
 }

tidoust added a commit to w3c/reffy that referenced this issue May 28, 2021
See related discussion in:
w3c/webref#51

This update adds a `styleDeclaration` property to CSS property definitions in
CSS extracts. The property contains the list of IDL attribute names that the
CSS property generates per the CSSOM spec on the `CSSStyleDeclaration`
interface:
https://drafts.csswg.org/cssom/#ref-for-css-property-to-idl-attribute

The implementation of the CSS property to IDL attribute algorithm was copied
over from:
https://github.com/foolip/mdn-bcd-collector/blob/c2126e8f367f08333a0f7b0604e42c8fdc11d182/build.js#L569
tidoust added a commit to w3c/reffy that referenced this issue May 28, 2021
See related discussion in:
w3c/webref#51

This update adds a `styleDeclaration` property to CSS property definitions in
CSS extracts. The property contains the list of IDL attribute names that the
CSS property generates per the CSSOM spec on the `CSSStyleDeclaration`
interface:
https://drafts.csswg.org/cssom/#ref-for-css-property-to-idl-attribute

The implementation of the CSS property to IDL attribute algorithm was copied
over, with @foolip approval as author [1], from:
https://github.com/foolip/mdn-bcd-collector/blob/c2126e8f367f08333a0f7b0604e42c8fdc11d182/build.js#L569

[1] #611 (review)
tidoust added a commit that referenced this issue Jun 1, 2021
This adjusts workflows to also handle and release a `@webref/elements` package,
as discussed in #51. Tests guarantee that interfaces that appear in the package
also exist in the `@webref/idl`.

Ideally, the IDL package should be added as peer dependency to the elements
package but that creates a chicken-and-egg situation as we will likely often
release packages together.

Patches are an overkill for now but could prove useful in the long run.

The update also splits CSS, elements, and IDL tests. That is a first step
towards addressing #237. It does not fully solve it though, as IDL patches are
still applied when the CSS package is released.
tidoust added a commit that referenced this issue Jun 2, 2021
This adjusts workflows to also handle and release a `@webref/elements` package,
as discussed in #51. Tests guarantee that interfaces that appear in the package
also exist in the `@webref/idl`.

Ideally, the IDL package should be added as peer dependency to the elements
package but that creates a chicken-and-egg situation as we will likely often
release packages together.

Patches are an overkill for now but could prove useful in the long run.

The update also splits CSS, elements, and IDL tests. That is a first step
towards addressing #237. It does not fully solve it though, as IDL patches are
still applied when the CSS package is released.
@tidoust
Copy link
Member

tidoust commented Jun 2, 2021

All CSS properties descriptions now contain a styleDeclaration property.
Released in @webref/css@1.1.0.

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

No branches or pull requests

3 participants