Re: Change to Attr interface in light of XPath

> On Tue, Mar 18, 2014 at 10:33 AM, Anne van Kesteren <annevk@annevk.nl <annevk@annevk.nl?Subject=Re%3A%20Change%20to%20Attr%20interface%20in%20light%20of%20XPath&In-Reply-To=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E&References=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E>> wrote:
>> On Tue, Feb 18, 2014 at 5:20 PM, Jonas Sicking <jonas@sicking.cc <jonas@sicking.cc?Subject=Re%3A%20Change%20to%20Attr%20interface%20in%20light%20of%20XPath&In-Reply-To=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E&References=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E>> wrote:
>>> attributenode.parentNode has always returned null. In all versions of
>>> the spec and in all implementations. What you want is
>>> attributenode.ownerElement. I'm surprised that it's been removed from
>>> the new spec. I agree that it needs to be put back.
>>
>> Why?
>>
>> It returns undefined in all implementations. (I didn't test this and
>> just went by your word initially, reverting that now.)
>
> I guess that at some point Gecko and other browsers removed this
> property since it was removed from the spec.

Exactly. This was removed from Gecko in https://bugzil.la/957431.

Seems the changes made there will be backed out now.

XPath expressions are not the only use-case for 'ownerElement',
though. Also DOM traversal via NodeIterators and TreeWalkers benefit
from this.

> On Tue, Mar 18, 2014 at 8:49 PM, Anne van Kesteren <annevk@annevk.nl <annevk@annevk.nl?Subject=Re%3A%20Change%20to%20Attr%20interface%20in%20light%20of%20XPath&In-Reply-To=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E&References=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E>> wrote:

>> On the other hand, it seems somewhat silly to remove ownerElement
>> since the implementation needs to hold a reference from the Attr
>> object to the Element anyway in order to implement the .value setter.
>
> Maybe we can make that property readonly?

I guess so.

> Tue, 18 Mar 2014 13:35, Jonas Sicking <jonas@sicking.cc <jonas@sicking.cc?Subject=Re%3A%20Change%20to%20Attr%20interface%20in%20light%20of%20XPath&In-Reply-To=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E&References=%3CCA%2Bc2ei-NHNNspJ8y1YHuiAQ67-9AURsTXJ903L%3DGCoruXJ5eWA%40mail.gmail.com%3E>> wrote:

> Seems silly to remove this given that it creates a less elegant API,
> and that it doesn't really reduce implementation burden (you still
> have to have a reference back to the element from the Attr object).

Totally agree.
FWIW one implementation that suffered from the removal of
'ownerElement' was Firebug.[1] The use case there is DOM traversal via
a TreeWalker.

Sebastian

[1] http://code.google.com/p/fbug/issues/detail?id=7108

Received on Wednesday, 19 March 2014 08:01:07 UTC