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

On Mon, 24 Feb 2014 17:01:31 +0100, Jirka Kosek <jirka@kosek.cz> wrote:

> On 24.2.2014 15:38, Simon Pieters wrote:
>>> ::attr(*) should select all attributes to be consistent with universal
>>> selector, equivalent to ::attr(*|*)
>>
>> This is not exactly consistent with the universal selector, since it  
>> uses
>> the default namespace:
>>
>> @namespace "foo";
>> @namespace a "foo";
>> * {}
>> a|* {}
>>
>> Those two are equivalent but different to *|*.
>
> As I wrote before, default namespace is not applied to attributes, so
> for ::attr() it doesn't make sense to take default namespace into  
> account.

Yeah, I don't disagree, but it doesn't make it consistent with the  
universal selector.

> Consider document:
>
> <foo xmlns="http://www.example.com/">
>   <bar x="1" y="2"/>
> </foo>
>
> and default namespace declared for selectors:
>
> @namespace "http://www.example.com/";
>
> then with what you seem to propose
>
> bar ::attr(*)
>
> would return no attributes. That seems counter intuitive and different
> to what developers would expect.
>
> As * was not in past used for attributes (it's not even allow inside
> attr() function) I don't see why behaviour couldn't be as I propose.

I think the proposed behavior is reasonable, I was just calling out that  
it is not consistent with the universal selector as claimed.

>>> This is also consistent with XPath, and should create less surprises to
>>> developers.
>>
>> Consistency with XPath seems like a weird motivation if the move to
>> Selectors in ITS was because people are more familiar with Selectors.
>
> Consistency with XPath is just additional benefit here, not reason to
> model feature this way.

OK.

>> When would you want to select all attributes, by the way?
>
> When there is a need to operate on all attributes.

Can you give a concrete case?

>> How do you declare a namespace prefix for the selector in ITS when using
>> Selectors?
>
> By using in-scope declared namespaces -- same way as in XPath. Although
> this is not explicitly stated in ITS 2.0.

That it's not stated seems like a bug.

-- 
Simon Pieters
Opera Software

Received on Tuesday, 25 February 2014 08:41:20 UTC