MCPcopy
hub / github.com/yabwe/medium-editor / detach

Function detach

spec/dyn-elements.spec.js:265–292  ·  view source on GitHub ↗
(node, async, fn)

Source from the content-addressed store, hash-verified

263});
264
265function detach(node, async, fn) {
266 var parent = node.parentNode,
267 next = node.nextSibling;
268 // No parent node? Abort!
269 if (!parent) {
270 return;
271 }
272 // Detach node from DOM.
273 parent.removeChild(node);
274 // Handle case where optional `async` argument is omitted.
275 if (typeof async !== 'boolean') {
276 fn = async;
277 async = false;
278 }
279 // Note that if a function wasn't passed, the node won't be re-attached!
280 if (fn && async) {
281 // If async == true, reattach must be called manually.
282 fn.call(node, reattach);
283 } else if (fn) {
284 // If async != true, reattach will happen automatically.
285 fn.call(node);
286 reattach();
287 }
288 // Re-attach node to DOM.
289 function reattach() {
290 parent.insertBefore(node, next);
291 }
292}

Callers 1

runAddTestFunction · 0.85

Calls 1

reattachFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…