atom feed72 messages in org.w3.public-webapiRe: ACTION-87: Selectors API
FromSent OnAttachments
4 earlier messages
Daniel SchierbeckFeb 25, 2006 11:28 am 
Jim LeyFeb 25, 2006 11:47 am 
Ian HicksonFeb 25, 2006 3:56 pm 
Cameron McCormackFeb 25, 2006 4:46 pm 
Lachlan HuntFeb 25, 2006 4:58 pm 
Cameron McCormackFeb 25, 2006 5:01 pm 
Daniel SchierbeckFeb 25, 2006 5:25 pm 
Anne van KesterenFeb 26, 2006 2:21 am 
Cameron McCormackFeb 26, 2006 2:33 am 
Cameron McCormackFeb 26, 2006 1:04 pm 
Maciej StachowiakFeb 26, 2006 3:03 pm 
Jonas SickingFeb 28, 2006 1:57 pm 
Ian HicksonMar 6, 2006 12:33 pm 
Ian HicksonMar 6, 2006 12:35 pm 
Anne van KesterenMar 22, 2006 2:30 am 
Anne van KesterenMar 22, 2006 2:33 am 
Anne van KesterenMar 22, 2006 2:35 am 
mozerMar 22, 2006 3:16 am 
Anne van KesterenMar 22, 2006 3:58 am 
mozerMar 22, 2006 4:30 am 
Anne van KesterenMar 22, 2006 4:37 am 
Jim LeyMar 22, 2006 5:43 am 
Anne van KesterenMar 22, 2006 6:08 am 
Jim LeyMar 22, 2006 6:45 am 
Maciej StachowiakMar 22, 2006 11:16 am 
Maciej StachowiakMar 22, 2006 11:22 am 
Maciej StachowiakMar 22, 2006 11:25 am 
Robin BerjonMar 22, 2006 2:01 pm 
Maciej StachowiakMar 22, 2006 2:28 pm 
Ian HicksonMar 22, 2006 2:48 pm 
Ian HicksonMar 22, 2006 2:51 pm 
Maciej StachowiakMar 22, 2006 3:20 pm 
Jim LeyMar 22, 2006 6:17 pm 
Jim LeyMar 22, 2006 6:24 pm 
Anne van KesterenMar 23, 2006 4:28 am 
Ian HicksonMar 23, 2006 2:31 pm 
Anne van KesterenMar 25, 2006 4:36 am 
Ian HicksonMar 27, 2006 3:13 pm 
Anne van KesterenApr 3, 2006 5:46 am 
Anne van KesterenApr 3, 2006 5:51 am 
lioreanMay 12, 2006 8:49 pm 
Anne van KesterenMay 13, 2006 4:15 am 
lioreanMay 13, 2006 12:08 pm 
Anne van KesterenMay 13, 2006 12:26 pm 
lioreanMay 13, 2006 2:40 pm 
Anne van KesterenMay 14, 2006 7:20 am 
lioreanMay 14, 2006 4:22 pm 
Anne van KesterenMay 15, 2006 3:15 am 
lioreanMay 16, 2006 9:29 pm 
Anne van KesterenMay 17, 2006 5:18 am 
18 later messages
Subject:Re: ACTION-87: Selectors API
From:Maciej Stachowiak (mj@apple.com)
Date:Mar 22, 2006 11:16:37 am
List:org.w3.public-webapi

On Mar 22, 2006, at 5:43 AM, Jim Ley wrote:

"Anne van Kesteren" <ann@opera.com>

On Sat, 25 Feb 2006 19:19:16 +0100, Daniel Schierbeck <dani@gmail.com> wrote:

This seems like a really good idea. I'm not sure about the method name.

There is now:

.match() .matchAll()

... per some discussion on #webapi. Thanks for your feedback.

as per later discussion on #webapi, please change these names, .match is too similar to match in ES, and I would expect it to take a regular expression (perfectly reasonable to run a regular expression over a DOM).

1) I think it's really useful to have these names be short. The fact that one of the most common operations you do by the dom is called document.getElementById is a huge disaster. We can afford some imprecision in the name in exchange for brevity if this is to be a common idiom.

2) I don't think trying to match a regular expression against the DOM is very sensible. But if you did want to do it, you could convert the DOM to a string. It's not unprecedented for operations with the same name to do different things based on the type. Consider the difference between 2 + 2 and "a" + "a" in ECMAScript. Or consider Array.indexOf vs. String.indexOf. Therefore I am not convinced by your argument that this similarity is problematic.

Also it's very odd to have .match() return only the first of something, it should return all of them, like everywhere else the name is used to avoid confusion (I'm not sure of the use case of just matching one anyway, please provide - if it's scripting performance, let's have a limit on the general case, because I often only what the first 4 things as much as only 1, gEBI covers the 1 case...)

Use case for matching one is to be able to easily operate on the first item when you know you have a unique match:

document.match("#header").addEventListener("click", headerClick, false);

Also, it is likely this can be done more efficiently than computing the whole static list and then getting the first item. I am sure there are other cases where a unique match is expected, such as looking for a specific attribute value:

document.match("iframe[name='ad-banner']").addEventListener("click", bannerClick, false);

I don't think the case of "first n for some arbitrary value of n" is common enough to be worth adding API for.

Mainly these names say nothing about their inescapable link to Selectors, they should.

Unfortunately the name document.selectNodes is taken by XPath, and select() would be easily confused with document.selection.

Regards, Maciej