Re: [selectors-nonelement] ::attr(*|localname), ::attr(ns|*), and ::attr(*)

On Mon, Feb 24, 2014 at 1:29 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 1:26 PM, Simon Sapin <simon.sapin@exyr.org> wrote:
>> On 24/02/2014 21:16, Tab Atkins Jr. wrote:
>>> In type selectors, "foo" and "*" are treated differently wrt
>>> namespaces when there's no default namespace.  "foo" is equivalent to
>>> "|foo", but "*" is equivalent to "*|*".
>>
>> That is not the case.
>>
>> http://dev.w3.org/csswg/selectors4/#typenmsp says:
>>
>> E
>>     if no default namespace has been declared for selectors, this is
>> equivalent to *|E. Otherwise it is equivalent to ns|E where ns is the
>> default namespace.
>
> Argh, why am I incapable of *reading*?


Okay, so synthesizing all this:

Default namespaces apply to type selectors, and the default default
namespace is "*".  That is, by default, "tag" is equivalent to
"*|tag".

Default namespaces do not apply to attribute selectors.  That is,
"[attr]" is equivalent to "[|attr]".  To get an attribute selector
that grabs attributes of a given name in *all* namespaces, you have to
be explicit: "[*|attr]".

It's probably worthwhile, for understandability, to have the attribute
pseudo-element work the same way as attribute selectors, so that
"::attr(title)" only selects title attributes in the null namespace.

However, there are probably use-cases for just grabbing all the
attributes on an element for processing, and it would be nice if this
was doable via something less verbose than "::attr(*|*)".  (Also, I
feel like that might look like something weird in ASCII-art, but I
can't quite tell what.)

I propose that if the argument is omitted, like "::attr()", we select
all attributes on the element.

~TJ

Received on Tuesday, 25 February 2014 00:33:03 UTC