Commit 2d73dbdb authored by Romain Courteaud's avatar Romain Courteaud

Speed up check if the element is attached to the DOM

parent 84717f1f
...@@ -284,7 +284,6 @@ ...@@ -284,7 +284,6 @@
function privateDeclareIframeGadget(url, options, parent_gadget) { function privateDeclareIframeGadget(url, options, parent_gadget) {
var gadget_instance, var gadget_instance,
iframe, iframe,
node,
iframe_loading_deferred = RSVP.defer(); iframe_loading_deferred = RSVP.defer();
if (options.element === undefined) { if (options.element === undefined) {
throw new Error("DOM element is required to create Iframe Gadget " + throw new Error("DOM element is required to create Iframe Gadget " +
...@@ -292,14 +291,7 @@ ...@@ -292,14 +291,7 @@
} }
// Check if the element is attached to the DOM // Check if the element is attached to the DOM
node = options.element.parentNode; if (!document.contains(options.element)) {
while (node !== null) {
if (node === document) {
break;
}
node = node.parentNode;
}
if (node === null) {
throw new Error("The parent element is not attached to the DOM for " + throw new Error("The parent element is not attached to the DOM for " +
url); url);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment