MCPcopy Create free account
hub / github.com/apache/cloudstack / replaceWith

Function replaceWith

tools/ngui/static/js/lib/angular.js:4641–4661  ·  view source on GitHub ↗

* This is a special jqLite.replaceWith, which can replace items which * have no parents, provided that the containing jqLite collection is provided. * * @param {JqLite=} $rootElement The root of the compile tree. Used so that we can replace nodes * in the root of the tree.

($rootElement, $element, newNode)

Source from the content-addressed store, hash-verified

4639 * @param {Node} newNode The new DOM node.
4640 */
4641 function replaceWith($rootElement, $element, newNode) {
4642 var oldNode = $element[0],
4643 parent = oldNode.parentNode,
4644 i, ii;
4645
4646 if ($rootElement) {
4647 for(i = 0, ii = $rootElement.length; i < ii; i++) {
4648 if ($rootElement[i] == oldNode) {
4649 $rootElement[i] = newNode;
4650 break;
4651 }
4652 }
4653 }
4654
4655 if (parent) {
4656 parent.replaceChild(newNode, oldNode);
4657 }
4658
4659 newNode[jqLite.expando] = oldNode[jqLite.expando];
4660 $element[0] = newNode;
4661 }
4662 }];
4663}
4664

Callers 2

applyDirectivesToNodeFunction · 0.85
compileTemplateUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected