Skip to content

[css-ui-4][css-images-4] Unify selector functions/values #5811

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

Open
SebastianZ opened this issue Dec 20, 2020 · 6 comments
Open

[css-ui-4][css-images-4] Unify selector functions/values #5811

SebastianZ opened this issue Dec 20, 2020 · 6 comments
Labels

Comments

@SebastianZ
Copy link
Contributor

There are currently several specs defining different ways for referencing (ID) selectors:

To improve the consistency between them, the syntax for referencing a selector should be merged.

Personally, I prefer the selector() function of Scroll Animations 1 because its name clearly outlines that it takes a selector and it is extensible as may allow other selectors then ID selectors in the future.

See also the related discussion in #5166. And depending on the outcome of #1981, CSS Images 4 might be changed to not have a specific selector function anymore.

Sebastian

@bramus
Copy link
Contributor

bramus commented Feb 4, 2021

Not blocking for this issue, but related to it: #5884

@tabatkins
Copy link
Member

The Images instance shouldn't be merged with the others - it's defining an <image>, not just acting as a generic element reference.

@SebastianZ
Copy link
Contributor Author

The Images instance shouldn't be merged with the others - it's defining an <image>, not just acting as a generic element reference.

And yet it is the one that is using the most generic name with the element() function. 😄 Though I get your point that this is somewhat special as it does two things, selecting an element and generating an image from it.

And because it's combining two functionalities in one, I'd suggest to rather split them up. With that I mean allowing selector() within <image-src>. With that change, the image would be generated using the image() function, so to generate an image from an element one would then write something like image(selector(#my-image)).

Sebastian

@bramus
Copy link
Contributor

bramus commented Jul 14, 2021

Building further upon what @SebastianZ suggested: if selector() would indeed behave more like document.querySelector, adding support for & (as borrowed from css-nesting) would also allow to refer to “self” (and more)

This would come in very handy for scroll-linked animations, where you now have to duplicate timelines (see #5884)

Above that, the whole idea for being more like document.querySelector would:

  • feel familiar to CSS developers as they already know the possibilities of using selectors
  • not introduce any new keywords such as self into specs: “use selector(&) instead”

@MattWilcox
Copy link

I'm with Bramus on this one; re-use the familiar and aim for parity with querySelector. Better for authors.

@flackr
Copy link
Contributor

flackr commented Aug 11, 2022

FWIW scroll-animations-1 is no longer using the selector() function. We are introducing scoped named timelines instead to handle this use case as it better allows for re-use.

@flackr flackr changed the title [css-ui-4][css-images-4][scroll-animations-1] Unify selector functions/values [css-ui-4][css-images-4] Unify selector functions/values Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants