liveclipboard
Wednesday, 26. July 2006, 20:13:03
liveclipboard is an interesting idea from Ray Ozzie. He's also blogged the process and brainstorming behind it. This is great..
Unfortunately it doesn't work in Opera.
The reason appears to be a bug in FireFox regarding how it evaluates XPath expressions. The document.evaluate spec states that the context node must belong to the same document as the method is called on. (The style is somewhat convoluted, I'm not 100% sure I've understood the phrase If the XPathEvaluator was obtained by casting the Document correctly but I can't think of any other reading that makes sense).
So, if you call document.evaluate( expression, someOtherDocument ...), Opera follows the spec to the t and throws an exception while FireFox doesn't. The liveclipboard script relies on this FireFox bug.
The fix is simple: import the nodes to the current document before XPathing them. For example:
hCardXmlNode = domParser.parseFromString(hCardXmlString, 'application/xml');
should be
hCardXmlNode = document.importNode(domParser.parseFromString(hCardXmlString, 'application/xml').firstChild, true);
One of these cases where testing in multiple browsers will highlight your assumptions about web standards.