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

Le 09/11/2013 15:23, Simon Sapin a écrit :
> Le 04/11/2013 20:59, Jirka Kosek a écrit :
>> For many cases Selectors would be just
>> enough, but currently they are missing key feature -- ability to
>> select attributes in a document tree. With such ability it would be
>> possible to rewrite previous rule as:
>>
>>    <its:rules xmlns:its="http://www.w3.org/2005/11/its"
>>               queryLanguage="css">
>>       <its:translateRule selector="@title" translate="yes"/>
>>    </its:rules>
>
> Could ITS specify the attribute name separately?
>
> <its:translateRule selector="*" attribute="title" translate="yes"/>
>

As to Selector API, it can be combined with Element.getAttribute() :

     document.querySelector(selector).getAttribute(attribute)

Or:

     Array.prototype.map(
         document.querySelectorAll(selector),
         function(e) { return e.getAttribute(attribute) })

-- 
Simon Sapin

Received on Saturday, 9 November 2013 07:29:49 UTC