- From: Adam Barth <w3c@adambarth.com>
- Date: Thu, 4 Oct 2012 15:08:04 -0700
- To: Adam Klein <adamk@chromium.org>
- Cc: whatwg@whatwg.org
You can also create contextless documents via XMLHttpRequest. Presumable <img> elements in XMLHttpRequest-created documents shouldn't be kicking off network requests! :) Adam On Thu, Oct 4, 2012 at 2:53 PM, Adam Klein <adamk@chromium.org> wrote: > With DOMImplementation.createDocument and createHTMLDocument, it's > possible to create Document objects that have no associated browsing > context. The behavior of elements created by that document is, in some > cases, well-specified. For example, <script> tags do not execute if > there is no browsing context > (http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-n-noscript). > > But some behavior is left unspecified, and is implemented differently > across browsers. For example, the following snippet: > > var doc = document.implementation.createHTMLDocument('myTitle'); > var img = doc.createElement('img'); > img.src = 'http://foo.com/myImage.png'; > > causes the img's src to be fetched by Opera, IE (only tested in 9, > since previous versions do not implement createHTMLDocument()), while > neither Gecko nor WebKit load the image. I haven't tested all elements > that load external resources, but I suspect that the behavior is > similar for, e.g., <audio> and <video>, where supported (<script src> > is something of an oddball: only IE tries to load that file when in a > context-less document). > > I'd propose that the Gecko and WebKit behavior is the most sensible. > For one, it seems more consistent to make everything in the > context-less Document inactive in the same way <script> is. And at > least some developers already depend on this behavior (see, e.g., this > StackOverflow discussion: > http://stackoverflow.com/questions/7738046/what-for-to-use-document-implementation-createhtmldocument). > > Seems like this should be specced in HTML (not sure whether it would > go in each resource fetching algorithm or somewhere more general). > > - Adam
Received on Thursday, 4 October 2012 22:09:03 UTC