Re: [csswg-drafts] [css-images] [css-gcpm] Overloaded definitions of element() (#1981)

@cdoublev wrote:

> I'm not sure that selecting an element via other types of selectors would be an upside. An image value referencing an element will always resolves to a single (~= unique, like an ID) target, while other selectors are more often used to select multiple targets.

You might be surprised that even ID selectors can match multiple elements, see https://jsfiddle.net/SebastianZ/qumshra7/. So the algorithm behind that feature already needs to take that into account and pick the first matched element. The spec. currently mentions this as "The ID is first looked up in the elementSources map".
This basically means the logic works similarily to `document.querySelector()` in JavaScript to pick just the first matched element.

But anyway, I am not completely against reusing `url()` for this purpose, though as I wrote earlier, the main downside is the missing feature detectability via `@supports`, which means you can't provide a fallback without JavaScript if it doesn't work in a user agent.

Also note that both solutions are non-exclusive.

Sebastian

-- 
GitHub Notification of comment by SebastianZ
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1981#issuecomment-749835993 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 22 December 2020 23:34:17 UTC