- From: David Flanagan <dflanagan@mozilla.com>
- Date: Tue, 04 Oct 2011 10:26:18 -0700
- To: www-dom@w3.org
- Message-ID: <4E8B41BA.5030204@mozilla.com>
Back in June I asked for clarification of the ownerDocument of a Document object: On 6/3/11 2:34 PM, David Flanagan wrote: > Both Firefox and Chrome make the ownerDocument of a Document node null. > > The June 3rd spec just says: >> The |ownerDocument| attribute must return the |Document >> <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#document>| >> node that the context object >> <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#context-object> >> is associated with, or null if there is none. > The meaning of this depends on whether a node is "associated with" itself. > > But the (new, I think) algorithm to ensure that two node are in the > same document requires document.ownerDocument === document, or it will > fail in the case of inserting a doctype into a document. > > David > Jonas wrote: > DOM Level 3 pretty explicitly says that document.ownerDocument === null > > http://www.w3.org/TR/DOM-Level-3-Core/core.html#node-ownerDoc > > However this was a part of the spec that I never liked, and I'd love > to change it. Are there browsers that set document.ownerDocument === > document? > > / Jonas And Aryeh wrote: > IE9, Firefox 5.0a2, Chrome 13 dev, and Opera 11.11 all say null. I > agree that this is obnoxious. I wound up writing a helper function > for my test suites that's basically function(node) { return > node.nodeType == Node.DOCUMENT_NODE ? node : node.ownerDocument }. > But it's not clear we can change it at this point. And then the thread devolved into a discussion of mutation events... :-) Anyway, the DOM 4 spec is now explicit: > > The |ownerDocument| attribute must return the node document > <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-document>. > > > The node document > <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-document> > of a document > <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document> > is that document > <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document> > itself. > > All nodes > <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node> have > a document > <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-document> > at all times. > The reason I'm reviving this thread is that we've implemented this, and have discovered that having document.ownerDocument === document breaks jQuery (1.6.4 and presumably other versions as well) We're filing a bug against jQuery, but I'm bringing this up here because I suspect that this new data point might cause browser vendors to reconsider whether they're willing to implement this change from the status quo. David
Received on Tuesday, 4 October 2011 17:26:57 UTC