- From: Michael A. Puls II <shadow2531@gmail.com>
- Date: Thu, 10 Jan 2008 16:43:37 -0500
- To: www-dom@w3.org
var test = document.createAttribute("foo"); test.value = "bar"; Firefox and Safari: test.childNodes is present. test.childNodes.length is 1. test.firstChild is present. test.firstChild.nodeValue returns "bar". IE: test.childNodes is null test.firstChild is null Opera: test.childNodes is present. test.childNodes.length is 0. test.firstChild is null. Firefox and Safari seem to create and append a text node to the attribute node for storing the value, which makes firstChild and nodeValue etc. available. In Opera, a text node is not created, or is created and only used internally and not revealed to public JS. This causes a problem for Opera at < http://www.betfair.com/ > under Games -> X-Blackjack -> turbo. The problem is (besides Opera being tagged as IE because the site checks for document.all and Opera reveals document.all) that the site actually makes use of .firstChild.nodeValue on attributes and the site breaks in Opera. I can only find one reason why Firefox and Safari might do this. Under < http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-221662474 >, it says "On setting, this creates a Text node ". Does that part in the spec really mean what Firefox and Safari do? Is what they do implied by Attr inheriting from Node? What is the correct behavior here? With .value available on attribute nodes, it doesn't seem like ..firstChild.nodeValue is even needed for value retrieval. To make that site work in Opera 9.5, I have to use UserJS like this: document.all = undefined; Attr.prototype.__defineGetter__("firstChild", function() { return this.ownerDocument.createTextNode(this.value); }); What should Opera do here? Thanks -- Michael
Received on Thursday, 10 January 2008 21:44:27 UTC