That's good. I don't have to change anything in base2, it'll pick it up
automatically. ;-)
-dean
Can you provide an example that fails? I haven't had any problems with
querySelectorAll() on Safari - I even tested on version 1.2!
-dean
Sorry, I missed the context of your comment. I assume you are using a
webkit nightly?
I guess I need to amend base2's StaticNodeList to accommodate a *real*
StaticNodeList!
base2 was not quite so future-proof as I thought. :-(
I'll look into this...
-dean
I'd like to check this out myself but I can't get the webkit nightly to
run on Windows and my Mac is too ancient. :-(
-dean
http://www.fu2k.org/alex/javascript/javascriptjunk/base2-staticnodelist-foreach
Works fine in everyhting other than the latest version of WebKit :(
>>>
line 12
Value undefined (result of expression
document.querySelectorAll("p").forEach) is not object.
<<<
At 16:15 +0000 11/2/08, Dean Edwards wrote:
>I guess I need to amend base2's StaticNodeList to accommodate a *real*
>StaticNodeList!
Presumably this means that anything else that gets patched and
amended (like your addClass sugar) will also fail.
Might it be an idea to extend the HTMLElement prototype directly if
the native querySelect is detected?
Bah! It's pretty easy to fix. base2's StaticNodeList object can wrap
anything that contains nodes. I just need a way to test it. :-(
Anyone got a clue how to get WebKit nightly to run on Windows? I've
tried and failed several times.
-dean
No. But send the updated code to me and I'll give it a go. ;)
Yes. On Arrays. Not on StaticNodeLists. I presume
that this is their considered judgement as to
what the new specs call for.
I don't think you'll be able to persuade WebKit
to add the enumeration stuff to StaticNodeList
unless you've persuaded the relevant javascript
WG first ;)
>Yes. But that's not what I meant: any element returned by
>querySelector() with base2 is "binded" and can use the methods base2
>adds to HTML elements. Even if webkit supported the enumeration
>methods on staticnodelists, that wouldn't change the heart of the
>problem: the elements in the staticnodelist wouldn't be binded, would
>they? (It's difficult to test for me at the moment)
That's what I was getting at when I wrote:
<<<
Presumably this means that anything else that gets patched and
amended (like your addClass sugar) will also fail.
Might it be an idea to extend the HTMLElement prototype directly if
the native querySelect is detected?
<<<
Now, if WebKit is correct and the specs don't
call for enumeration methods on StaticNodeLists,
then the correct solution is probably to remove
the support in Base2.DOM.
After all, the primary concern of Base2.DOM is to
get all browsers in line and behaving according
to the standards. (Dean?)
But yes, I hope to god, that these methods are added....
I think the enumeration methods are too nice to leave out, also, we need
a mechanism to apply bindings as Mathieu pointed out.
This shouldn't be too difficult to fix. base2's StaticNodeList is just a
wrapper for an array of nodes or an XPath result. It can easily wrap a
*real* StaticNodeList.
I just need to be able to test it. :-)
Are people in a hurry for this change or is it just academic interest?
Whilst we are on the subject:
http://www.whatwg.org/specs/web-apps/current-work/#domtokenlist
I plan to replace the addClass/removeClass/etc methods with the HTML5
classList object. Anybody against this idea?
-dean
Ahem. base2 was the first to implement. ;-)
-dean
Gah! /aol me too!
>Are people in a hurry for this change or is it just academic interest?
I think it's academic until this version of WebKit hits the streets.
Given all the recent additions I think we can safely assume that this
is not super imminent.
>Whilst we are on the subject:
>
>http://www.whatwg.org/specs/web-apps/current-work/#domtokenlist
>
>I plan to replace the addClass/removeClass/etc methods with the HTML5
>classList object. Anybody against this idea?
One of the things that I like about the removeClass and hasClass
implementations in Base2 is that (whether they're meant to or not) is
that they allow for regexes to be used. Does the DOM token list allow
for this? My head just starts to spin reading through stuff about
tokenisation...
The classList functions will work in exactly the same way.
I'm keen to add support for this. That only leaves the previously
discussed matchesSelector() method as being non-standard. Everything
else in base2.DOM has been specified by the W3C or WHATWG.
-dean
I always get an error when I run that:
> The syntax of the command is incorrect. '"C:\Documents and
> Settings\DEAN~1.93F\LOCALS~1\Temp\run-webkit-nightly2.cmd"' is not
> recognized as an internal or external command, operable program or
> batch file.
Any ideas?
> You might need a copy of the latest non-nightly installed before you
> do.
I have the latest beta is that good enough?
-dean
Don't worry, I've already written a little function that will add the
old methods back if needs be. Untested, but looks something like this:
with (base2) with (JavaScript.Function2) with (DOM) {
ClassList.forEach(function(method, name) {
HTMLElement[name + "Class"] = bind(method, ClassList);
});
}
I will always try to provide an upgrade path if I make changes to the
API. The trouble is that a lot of the specs I'm implementing are in a
state of flux themselves. Witness the Selectors API naming debacle. I
have a JSON library that I'm holding back because the ES4 editors can't
make up their minds.
> When do you think the update will land in SVN?
Not for at least two weeks.
-dean
Phew. Most excellent.
>I'm keen to add support for this. That only leaves the previously
>discussed matchesSelector() method as being non-standard. Everything
>else in base2.DOM has been specified by the W3C or WHATWG.
I totally support this move Dean. Anyone who is using base2 should be
linking to one of the beta versions (if not local code) rather than
the working copy and so addClass etc will stay supported for them
(ok, me ;) until they choose to upgrade.
I've fixed this in the trunk. Will update the libs soon.
-dean
That's fixed too.
-dean
OK. I will release a new version as soon as possible.
-dean