W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2014

Re: Change to Attr interface in light of XPath

From: Justin Summerlin <justin@inkling.com>
Date: Fri, 28 Feb 2014 18:28:56 -0800
Message-ID: <CAA2YHm4HOE9hY8Ob4WeA9kiScEGfzAC5EGqZbNwjf=bVOXgdMg@mail.gmail.com>
To: steve@fenestra.com
Cc: Robin Berjon <robin@w3.org>, Jonas Sicking <jonas@sicking.cc>, Boris Zbarsky <bzbarsky@mit.edu>, DOM public list <www-dom@w3.org>
I still feel like it's a bit strange that you can now get things back from
browser XPath queries that you can't treat as Nodes. Instead of checking
nodeType, you just have to do other things with it, or re-write all of your
queries. I don't think the majority of people see a huge benefit from this
change, so the loss of consistency between multiple technologies doesn't
make much sense to me.

What do we need to do to have ownerElement added back to Attr? Do I need to
file a bug somewhere?


On Wed, Feb 19, 2014 at 8:34 AM, Steve Schafer <steve@fenestra.com> wrote:

> On Wed, 19 Feb 2014 12:18:03 +0100, you wrote:
> >Inheriting fully from Node is pretty heavy-handed, and for many things
> >feels quite unnatural.
> >
> >Do you have an implementation of XPath in JS? Maybe the simplest thing
> >would be to show what information you need on Attr for it to work; it's
> >likely to cover general-purpose requirements pretty well.
> There seem to be two separate things being intertwined here:
> 1) support of XPath, and
> 2) availability of navigational methods on attribute objects vs. those
> on "normal" nodes.
> As for (1), all that is required is that both "normal" nodes and
> attributes support XPath navigation.
> That is, given the de facto standard JavaScript XPath syntax:
>  document.evaluate(<expression>, <contextNode>, ...)
> the implementation has to be willing to accept an attribute object as
> the <contextNode> argument. If you do something silly like trying to get
> the descendants of an attribute, or the attributes of a text node, you
> just get an empty result set. No harm, no foul.
> As for (2), that doesn't have anything to do with XPath per se. You may
> have gotten to a node or attribute via XPath, but as soon as you start
> calling DOM object navigational methods, XPath is out of the picture.
> Finally, getting back to the OPs original issue, if you want to stick to
> pure XPath, a query expression of ".." will return an attribute's owner
> element.
> -Steve Schafer
Received on Saturday, 1 March 2014 02:31:04 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:04 UTC