« SproutCore Is Crap | Main | Extensions and Firefox 3 - nsICookieService Behavior Change »
June 24, 2008
document.createExpression change between Firefox 2 and Firefox 3
Ran into this with an IBM product I am working on:
In Firefox 3 (Gecko 1.9), there seems to have been a change that affects XPath and document.createExpression. In particular, you now have to call createExpression on the document you will run the XPath against. Before, you could call createExpression on another document.
In Firefox 2, the following would work:
var expr = document.createExpression(...);
expr.evaluate(anotherDocument, ...)
In Firefox 3, you will get:
Node cannot be used in a document other than the one in which it was created" code: "4
Example showing this: http://nexgenmedia.net/mozilla/playgroundxpath.html
Hopefully this will save people time when running into this.
Posted by doron at June 24, 2008 9:34 AM
Trackback Pings
TrackBack URL for this entry:
http://weblogs.mozillazine.org/mt/track.cgi/12693
Comments
Docs updated:
http://developer.mozilla.org/en/docs/DOM:document.createExpression
Posted by: Mark Finkle at June 24, 2008 6:25 PM
Thanks for the info,
that also means, that document.evaluate have to be run onto the right element. Since my getElementsByClassName supports the native one, that wasnt a problem for Firefox 3. But maybe some day other browsers behaivoir change in a way like Firefox does, but doesnt support native getElementsByClassName.
But that that now alos covered by my function: http://phpfi.com/327120
Fabian
Posted by: Fabian at June 28, 2008 10:28 AM