Re: Moving an iframe in the DOM

On Fri, 16 Mar 2012 05:31:08 +0100, John J Barton  
<johnjbarton@johnjbarton.com> wrote:

> The HTML5 spec has:
>
> "Removing an iframe from a Document does not cause its browsing
> context to be discarded. . Indeed, an iframe's browsing context can
> survive its original parent Document if its iframe is moved to another
> Document."

This is just a statement of fact, not a requirement. The spec would mean  
the same thing (i.e. have the same normative requirements) if this text  
was removed. If it were to be discarded, there would need to be a  
requirement saying to discard it when the iframe is removed, or some such,  
I think.

> To me this statement is ambiguous, since we don't know what 'not ...
> discarded' or "survive' means.  Does 'survive' mean that the values in
> the browsing context remain intact?  If the context were to say issue
> setInterval based computations, would these continue?

Let's see.

http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-setinterval

"Wait: If the method context is a Window object, wait until the Document  
associated with the method context has been fully active for a further  
interval milliseconds (not necessarily consecutively).
...
Queue the task task."

If the new document the iframe is moved to is also fully active, then  
setInterval would continue normally. If it isn't (e.g. because it doesn't  
have a browsing context), then the setInterval would hang on the waiting  
step.

> I am doing the equivalent of:
>   document.body.appendChild(iframe);
>   // sometime after the load event:
>   anotherElement.appendChild(iframe);
>
> The second appendChild should remove the iframe element from the
> document and then insert it under anotherElement. And it does.
>
> However the properties of the window object that I set are not retained.

The spec doesn't say to remove properties of the window when moving an  
iframe, so that would be a bug.

> If I look at the value of iframe.contentWindow.editorInterface before
> the second appendChild(), it has the values I defined in the iframe.
>
> If I look at the value after the second appendChild() it is 'undefined'.
>
> I can't tell from the spec if this is a bug or not. Do we know?
>
> jjb

HTH
-- 
Simon Pieters
Opera Software

Received on Friday, 16 March 2012 08:45:46 UTC