Re: [selectors] Anonymous Attribute Selector

Tab Atkins Jr. <jackalmage@gmail.com>:
> On Fri, May 30, 2014 at 2:33 AM, Christoph Päper
>> There currently is no way in Selectors to match such anonymous attributes, but there’s kind of a way to match anonymous elements with the universal selector which is optional in ID, class, pseudo-class, pseudo-element and attribute selectors.
> 
> Selectors defines a data model in terms of the DOM, but that doesn't
> mean that your markup has to map into the DOM in exactly the way that
> HTML would.
> 
> In particular, you should feel free to define that your language maps
> the unnamed attribute into a DOM attribute named "attr" or something
> for the purposes of Selectors.

Sure, that could work today, but why shouldn’t there be a generic solution for attributes when there is one for elements? 

The universal element selector is actually used a lot, 
although usually in its implicit form wherein the optional asterisk ‘*’ isn’t used:

  .class
  #id
  :pseudo
  [attribute]

It’s used explicitly the most in descendant selectors 
(and when targeting browser parsing bugs).

  foo>*>bar
  foo * bar

A universal attribute selector would encompass my anonymous attribute selector, 
because if it selects any attribute it doesn’t matter whether that’s named, implicit or anonymous. 
So I would like to upgrade my proposal accordingly.

  [@]

selects a node that has any attribute specified, but

  attr(@)

still only uses the [first?] anonymous attribute.

  []

remains a syntax error and selects nothing and

  attr()

also fails to do anything useful.

In HTML4/RFC1942, for instance,

  table[@="border"]

unlike

  table[border]

would be a correct way to match

  <table border>

since that’s shorthand for

  <table frame="border">

but

  table[frame]
  table[frame="border"]

should both match then, too, of course.
In BBCode,

  [URL=http://example.com]foo[/URL]

would be matched by

  URL[@*="example.com"]

Received on Monday, 2 June 2014 09:11:52 UTC