W3C home > Mailing lists > Public > www-style@w3.org > November 2013

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

From: Simon Sapin <simon.sapin@exyr.org>
Date: Sat, 09 Nov 2013 15:29:22 +0800
Message-ID: <527DE452.7040706@exyr.org>
To: Jirka Kosek <jirka@kosek.cz>, www-style list <www-style@w3.org>
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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:36 UTC