MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / resolveElementClasses

Function resolveElementClasses

code/songhop/www/lib/angular/angular.js:4562–4586  ·  view source on GitHub ↗
(element, classes)

Source from the content-addressed store, hash-verified

4560 }
4561
4562 function resolveElementClasses(element, classes) {
4563 var toAdd = [], toRemove = [];
4564
4565 var hasClasses = createMap();
4566 forEach((element.attr('class') || '').split(/\s+/), function(className) {
4567 hasClasses[className] = true;
4568 });
4569
4570 forEach(classes, function(status, className) {
4571 var hasClass = hasClasses[className];
4572
4573 // If the most recent class manipulation (via $animate) was to remove the class, and the
4574 // element currently has the class, the class is scheduled for removal. Otherwise, if
4575 // the most recent class manipulation (via $animate) was to add the class, and the
4576 // element does not currently have the class, the class is scheduled to be added.
4577 if (status === false && hasClass) {
4578 toRemove.push(className);
4579 } else if (status === true && !hasClass) {
4580 toAdd.push(className);
4581 }
4582 });
4583
4584 return (toAdd.length + toRemove.length) > 0 &&
4585 [toAdd.length ? toAdd : null, toRemove.length ? toRemove : null];
4586 }
4587
4588 function cachedClassManipulation(cache, classes, op) {
4589 for (var i=0, ii = classes.length; i < ii; ++i) {

Callers 1

angular.jsFile · 0.70

Calls 2

createMapFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected