Bookmarklets updated to comply with DOM 2 rule
DOM 2 does not allow nodes to be moved between documents -- in fact, it requires that implementations throw an error when code tries to do so. But for years, Gecko has not enforced this rule.
It's a bit embarrassing that Internet Explorer gets this right and we get it wrong. Someone might think Gecko is trying to embrace and extend the DOM.
Soon, Gecko will start enforcing the rule on trunk. But bringing Gecko in line with this aspect of the DOM spec risks breaking Gecko-specific code, such as code in extensions and bookmarklets written for Firefox. For example, my Search Keys extension used to create some nodes in the chrome document, and some in the foreground tab, before putting them in the tab that that just loaded. Search Keys 0.8 creates all elements in the correct document.
I also updated the following bookmarklets to create nodes in the correct document and/or use importNode when copying nodes between documents:
- Validation bookmarklets: list alts
- Web development bookmarklets: partial source, view style sheets, view scripts
- Text and data bookmarklets: view selection
- Bookmarklets for testing browsers: clone document
These bookmarklets previously only worked in browsers that violated the DOM spec by allowing nodes to be moved between documents without a call to importNode or adoptNode. Maybe some of them work in IE now.
If you use those bookmarklets, you should grab the new versions so they won't break when you update to next week's trunk build or to Firefox 3.
November 3rd, 2006 at 7:53 pm
I don’t understand why this was implemented. I read through the bug, and I still don’t understand it. Do you have any ideas why its considered useful? IE + standards conformance doesn’t make sense to me, since DOM v3 (or v4) could just remove the requirement, and Gecko’s behaviour is a superset of IE’s behaviour.
Also, does a workaround just involve invoking innerHTML/removeChild (or something equivalent if that’s not standard enough)?
November 7th, 2006 at 5:58 am
I just hope Gecko won’t copy Internet Explorer’s error message here – I rarely see anything so useless and misleading :)
November 8th, 2006 at 8:42 pm
Gecko’s error message is “Node cannot be used in a document other than the one in which it was created” :)
November 9th, 2006 at 12:27 pm
Except for punctuation, it can’t be much better..:D
November 9th, 2006 at 8:11 pm
How would you improve its punctuation? No errors jump out at me…
November 10th, 2006 at 1:27 am
Though English is not my first language, nor my second, I am still pretty sure there is supposed to be a dot at the end of the error message. It is a sentence after all.
But it was more ment as irony. The error message can’t be missunderstood. Sorry, for the double confusion here. As long as the appendChild method works the way it was intended, I am happy..:)