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

Add BCD for CSS Anchor Positioning spec #22813

Merged
merged 18 commits into from
Apr 21, 2024

Conversation

chrisdavidmills
Copy link
Collaborator

@chrisdavidmills chrisdavidmills commented Apr 9, 2024

Summary

CSS Anchor Positioning is set to be released in Chrome 125. The associated Chrome Status entry does not appear to be very up-to-date, but I have been assured by Chrome engineering that this is the case.

This PR adds BCD for all the features in the spec, namely:

  • The anchor-name property
  • The anchor-scope property
  • The position-anchor property
  • The position-visibility property
  • The anchor() function
  • I've also added a subfeature to each of the properties that support anchor() as a value:
    • top
    • left
    • bottom
    • right
    • inset-block-start
    • inset-block-end
    • inset-inline-start
    • inset-inline-end
    • inset-block
    • inset-inline
    • inset
  • The anchor-center value, which is supported on the following properties (I've added a subfeature for each):
    • justify-self
    • align-self
    • justify-items
    • align-items
  • The anchor-size() function
  • I've also added a subfeature to each of the properties that support anchor-size() as a value:
    • width
    • height
    • min-width
    • min-height
    • max-width
    • max-height
    • block-size
    • inline-size
    • min-block-size
    • min-inline-size
    • max-block-size
    • max-inline-size
  • The inset-area property
  • The position-try-options property
  • The position-try-order property
  • The position-try shorthand property
  • The @position-try at-rule
  • The CSSPositionTryRule CSSOM interface and its properties:
    • name
    • style

Note that there are features that don't appear to be supported yet in Chrome, as of the creation of this PR — the anchor-scope property, and the position-try* properties/@position-try at-rule. AFAIUI, these should be added/enabled fairly soon, so I've added them in for now. I'll hopefully get a confirmation soon either way, so I can remove/retest as appropriate.

Note that there are also a couple of features that Chrome supports but aren't in a spec yet (see https://github.com/whatwg/html/pull/9144/files):

  • The HTML anchor attribute, used to declare the ID of an element that you want this element to be anchored to (i.e. its anchor element).
  • The Element.anchorElement property, used to access a reference to an element's anchor element.

I also added in data points for Chrome/CxA 125, so that my BCD doesn't error out.

Test results and supporting details

Related issues

@github-actions github-actions bot added data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API data:css 🎨 Compat data for CSS features. https://developer.mozilla.org/docs/Web/CSS data:html 📄 Compat data for HTML elements. https://developer.mozilla.org/docs/Web/HTML data:browsers 🌍 Data about browsers (versions, release dates, etc). This data is used for validation. labels Apr 9, 2024
@chrisdavidmills chrisdavidmills marked this pull request as draft April 10, 2024 09:59
@lukewarlow
Copy link
Contributor

lukewarlow commented Apr 11, 2024

I'm very dubious of that version 125 number. There's not afaik been an intent to ship yet, and https://chromiumdash.appspot.com/schedule suggests the cut off for Chrome 125 was April 1st?

Edit: okay that's an intent to ship now

@chrisdavidmills
Copy link
Collaborator Author

I'm very dubious of that version 125 number. There's not afaik been an intent to ship yet, and https://chromiumdash.appspot.com/schedule suggests the cut off for Chrome 125 was April 1st?

@lukewarlow yeah, that's a good point. @mfreed7 / @rachelandrew, do you have any updated information on this?

@mfreed7
Copy link
Contributor

mfreed7 commented Apr 11, 2024

I'm very dubious of that version 125 number. There's not afaik been an intent to ship yet, and https://chromiumdash.appspot.com/schedule suggests the cut off for Chrome 125 was April 1st?

@lukewarlow yeah, that's a good point. @mfreed7 / @rachelandrew, do you have any updated information on this?

https://groups.google.com/a/chromium.org/g/blink-dev/c/jGTYNuidPRs

@github-actions github-actions bot added the merge conflicts 🚧 This PR needs to merge latest "main" branch to resolve a merge conflict or other issue. label Apr 17, 2024
Copy link

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed data:browsers 🌍 Data about browsers (versions, release dates, etc). This data is used for validation. merge conflicts 🚧 This PR needs to merge latest "main" branch to resolve a merge conflict or other issue. labels Apr 17, 2024
api/Element.json Outdated
@@ -223,6 +223,39 @@
}
}
},
"anchorElement": {
Copy link
Member

Choose a reason for hiding this comment

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

The spec PR adds this to HTMLElement not Element. Also, I don't see Chrome 125 shipping this. Should we remove this for now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this is not included in what's shipping so I wouldn't include it in this dataset.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ooops! In my next commit, I've moved it to HTMLElement.

The thing is though, it is supported, not behind a flag, in Canary (I've tested it). I'm guessing it just won't be shipped in Chrome stable for some time. So I feel like it is useful to keep this data for folks doing testing of preview features.

How can we represent features in this state? I thought we used to have some kind of "preview" value to use for this, but I can't find mention of it in the BCD data schema doc.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for moving it. See #22813 (review) for setting preview and partial implementation because it is on the wrong interface at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm - the anchor attribute won’t ship in 125. (And current Canaries and Beta should not support it - Chris, please file a bug if you see some observable support.) We are still hoping to ship it soon once the spec discussion concludes, but I don’t know when that will be.

Copy link
Collaborator Author

@chrisdavidmills chrisdavidmills Apr 19, 2024

Choose a reason for hiding this comment

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

@mfreed7 OK, filed at https://issues.chromium.org/issues/335744345. Is that OK? I've never filed a Chromium bug before ;-)

So I should just remove this for now?

And, can I clarify — this is just the anchorElement property we are talking about? The anchor HTML attribute is still shipping?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm removing the anchor attribute in #22910.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, WFM

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for filing the bug - I just commented there. I suspect you have Experimental Web Platform Features enabled, which is why you see the anchorElement property available. Neither the anchor content attribute nor the anchorElement IDL attribute are shipping in Chrome in 125 or likely 126 at least.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mfreed7 OK, filed at https://issues.chromium.org/issues/335744345. Is that OK? I've never filed a Chromium bug before ;-)

Also, yes of course, that was perfect!

Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this Chris. I double-checked all of this against the @openwebdocs BCD collector and left some comments.

  • need to have sub features for property values.
  • anchorElement should probably be removed
  • anchor-scope seem unsupported, also remove?
  • What about adding the CSSPositionTryDescriptors interface?

css/properties/anchor-name.json Show resolved Hide resolved
css/properties/anchor-scope.json Outdated Show resolved Hide resolved
css/properties/inset-area.json Show resolved Hide resolved
css/properties/position-try-options.json Show resolved Hide resolved
css/properties/position-try-order.json Show resolved Hide resolved
css/properties/position-visibility.json Show resolved Hide resolved
@chrisdavidmills
Copy link
Collaborator Author

@Elchi3 ok, I think I've done everything you asked for here, except for CSSPositionTryDescriptors — that wasn't in the spec when I first submitted this PR.

Can you show me how to go about generating BCD for this? There's over 70 properties 😱

@Elchi3
Copy link
Member

Elchi3 commented Apr 19, 2024

Thanks Chris, so now you know why I said let's generate this stuff :))

A gist for you for CSSPositionTryDescriptors from the collector: https://gist.github.com/Elchi3/2fcdc552ec5defba79ffd789e398f901 (Doesn't yet contain spec_urls.)

api/HTMLElement.json Outdated Show resolved Hide resolved
Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

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

Thanks Chris! Ready from my side! 👍

@chrisdavidmills chrisdavidmills marked this pull request as ready for review April 21, 2024 21:07
@chrisdavidmills
Copy link
Collaborator Author

Super awesome, thanks @Elchi3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API data:css 🎨 Compat data for CSS features. https://developer.mozilla.org/docs/Web/CSS data:html 📄 Compat data for HTML elements. https://developer.mozilla.org/docs/Web/HTML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants