MCPcopy
hub / github.com/angular-ui/ui-router / addOrReuseElement

Function addOrReuseElement

test/angular/1.4/angular.js:27200–27218  ·  view source on GitHub ↗
(parent, current, type, templateElement)

Source from the content-addressed store, hash-verified

27198 }
27199
27200 function addOrReuseElement(parent, current, type, templateElement) {
27201 var element;
27202 // Check whether we can reuse the next element
27203 if (current && lowercase(current.nodeName) === type) {
27204 // The next element is the right type so reuse it
27205 element = current;
27206 } else {
27207 // The next element is not the right type so create a new one
27208 element = templateElement.cloneNode(false);
27209 if (!current) {
27210 // There are no more elements so just append it to the select
27211 parent.appendChild(element);
27212 } else {
27213 // The next element is not a group so insert the new one
27214 parent.insertBefore(element, current);
27215 }
27216 }
27217 return element;
27218 }
27219
27220
27221 function removeExcessElements(current) {

Callers 1

updateOptionsFunction · 0.85

Calls 1

lowercaseFunction · 0.70

Tested by

no test coverage detected