Re: Property Selector

On 7/19/10, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> 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"?
>

Yes.

> 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).
>

So the problem is where the property is a getter and that getter has
side effects and the side effects include modifying the DOM.

Is there a DOM property where that would happen or is this only a
possibility for expandos (user-defined setters)?

Garrett

Received on Monday, 19 July 2010 18:51:00 UTC