jquery bug: iframes being reloaded by domManip()

by jlgrall

HTML

<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<p id="clickMe">Click me to move me</p>
<iframe src="http://jsfiddle.net/jlgrall/xk7Jm/embedded/result,js,html/" width="100%" height="200"></iframe>
<p id="descr">The bug: the iframe is reloaded when its DOM node is moved.</p>

CSS

#clickMe { cursor: pointer; }

JavaScript

var iframe = $("iframe");
var iframeNode = iframe[0];
var text = $("#clickMe");
var textNode = text[0];

text.click(function() {
    // With jQuery:
    iframe.insertBefore(text);
    
    // With DOM manipulations:
    //iframeNode.parentNode.insertBefore(iframeNode, textNode);
});