Re: [selectors4] Proposal for extending Selectors Level 4 with possibility to select attributes

Le 04/11/2013 12:59, Jirka Kosek a écrit :
> I propose to add new type of simple selector which will allow
> selecting attribute nodes in a document tree.
>
> Proposed syntax is to use @attribute-name syntax, for example:
>
> img @alt      -- select alt attributes on images
>
> * @alt        -- select all title attributes
> [...]

Selecting attributes for a style rule in a CSS stylesheet doesn’t make 
sense. So I assume that this new feature would not exist there, only ITS 
and possibly Selectors API.

This means that it’s probably not a problem to use the @name syntax, as 
ambiguity with at-rules only exist in CSS stylesheets.

That said, I agree with Tab that a syntax pseudo-element like 
::attr(name) is more consistent with the rest of Selectors.

Regardless of syntax, this would have restrictions similar to 
pseudo-elements: the attribute part must be at the end of a selector.

(Also, we’ll need terminology to differentiate this for the existing 
"attribute selectors", which filter elements based on their attributes.)

-- 
Simon Sapin

Received on Tuesday, 5 November 2013 16:24:38 UTC