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

On Wed, 06 Nov 2013 23:57:26 +0100, Jirka Kosek <jirka@kosek.cz> wrote:

> On 6.11.2013 21:28, Simon Pieters wrote:
>> Can you please provide real examples where people select attributes in
>> JS and would benefit from this proposal? Can you demonstrate that people
>> are working around the lack of this feature (e.g. JS frameworks that use
>> Selectors with an extension like this)?
>
> Some XML editors use CSS extensively and they extend CSS in order to
> provide definition of visual editing mode, e.g.:
>
> http://www.xmlmind.com/xmleditor/_distrib/doc/csssupport/styling_attributes.html

Thanks, but that doesn't appear so relevant here since the proposal isn't  
to make the feature available in CSS.

> Speaking of JS libraries, isn't jQuery attr() what you are asking for:
>
> http://api.jquery.com/attr/

Not as far as I can tell. jQuery .attr() is a JS method, not part of its  
Selectors extensions. You would do something like:

$('img[alt]').attr('alt')

> jQuery has same extensions for Selectors -- some of them are available
> just as methods on jQuery object and some of them are also ported
> directly to Selectors syntax.

Is that the case for attr()? I can't find anything in the documentation.

>> I understand the ITS use case, but it's not clear to me that ITS is
>> something that Selectors should be catering for at this point. I don't
>> have anything against ITS per se, but I think it's useful to question if
>> it's a need that is relevant for the Web at large or just a niche thing.
>
> From Selectors 4 abstract:
>
> "Selectors are patterns ... that can be used to select nodes in an XML
> document."
>
> If Selectors are aiming to be universal selector/query language it
> should be possible to select different kinds of nodes in document, not
> just elements. Attributes are first candidate to be added, but for the
> sake of completeness I think that text and comment nodes should be added
> as well, and for XML document also processing instruction nodes.

No, we should add things based on use cases.

-- 
Simon Pieters
Opera Software

Received on Thursday, 7 November 2013 07:37:52 UTC