Re: Property Selector

On 7/19/10 3:24 AM, Garrett Smith wrote:
> Standard attribute selectors are more flexible than property
> selectors. They also fail silently if the attribute is missing.
>
> document.querySelectorAll("[noexist=blah]"); // 0
> document.querySelectorAll(":noexist"); // Error.
>
> Why no generic property selector?
>
> :property(name);
> :property(name=value)
>
> - where `value` is required to be an identifier or string [CSS2].
> Anyway, I thought it would be useful for the selectors API.
>
> Just wondering if this has occurred to anyone else.

By "property", do you just mean "get the JS reflection of the element 
and call the getter for the given property name"?

If so, that would significantly complicate selector matching (and make 
some very desirable selector-matching optimizations well-nigh 
impossible), due the fact that getters can modify state (unlike existing 
selectors, which can't change the state of the DOM while the selector is 
being matched against an element).

-Boris

Received on Monday, 19 July 2010 07:51:21 UTC