W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2011

Re: Improving DOM Traversal and DOM XPath

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 25 Apr 2011 14:29:11 -0700
Message-ID: <BANLkTinBR84vsyhPLsT2VyG=RZOLoEfduA@mail.gmail.com>
To: Ojan Vafai <ojan@chromium.org>
Cc: Webapps WG <public-webapps@w3.org>
On Mon, Apr 25, 2011 at 2:22 PM, Ojan Vafai <ojan@chromium.org> wrote:
> On Mon, Apr 25, 2011 at 11:31 AM, Jonas Sicking <jonas@sicking.cc> wrote:
>>
>> First off is document.createTreeWalker and
>> document.createNodeIterator. They have the same signature which
>> currently is:
>>
>> document.createX(root, whatToShow, filter, entityReferenceExpansion);
>>
>> Given that entity references are being removed, we should simply
>> remove the last argument. Note that this is a backwards compatible
>> change since additional arguments to any DOM function are just ignored
>> in all browsers I think. Additionally, I see no reason to keep the
>> 'filter' argument required as it's quite common to leave out.
>
> FWIW, WebKit already has filter and entityReferenceExpansion as optional. I
> expect there would be no opposition to making whatToShow optional as well.
>>
>> We could even make the whatToShow argument optinal and default it to
>> SHOW_ALL. Originally I was going to propose that we default it to
>> SHOW_ELEMENTS as I had thought that that would be a common value,
>> however it appears that SHOW_TEXT is as, if not more, commonly used.
>> The downside to defaulting to SHOW_ALL is that people might use the
>> default and then do filtering manually, which is slower than having
>> the iterator/treewalker do the filtering.
>
> I agree with everything here. I think SHOW_ALL is the default people would
> expect.

Excellent!

>> I'd like to give some DOM XPath a similar treatment. The following
>> three functions could be simplified:
>>
>> XPathEvaluator.createExpression(expression, resolver);
>> Here I think we can make the 'resolver' argument optional as
>> namespaces are commonly not used on the web.
>>
>> XPathEvaluator.evaluate(expression, contextNode, resolver, type, result);
>> We can make 'resolver', 'type' and 'result' optional. 'type' would
>> default to ANY_TYPE(0) and the other two to null.
>>
>> XPathExpression.evaluate(contextNode, type, result);
>> Here all but the first could be optional. The defaults would be the
>> same as for XPathEvaluator.evaluate.
>
> These are already all optional in WebKit. We could also make contextNode
> optional by defaulting it to the document, no?

Yup, that would be fine with me.

>> I'd like to make these changes to firefox, but first I wanted to hear
>> what people here think.
>
> I support this. As it is, I believe the verbosity of these methods hurts
> their adoption.

That was my thinking exactly.

/ Jonas
Received on Monday, 25 April 2011 21:30:13 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:44 GMT