(element, add, remove)
| 4851 | }; |
| 4852 | |
| 4853 | function addRemoveClassesPostDigest(element, add, remove) { |
| 4854 | var data = postDigestQueue.get(element); |
| 4855 | var classVal; |
| 4856 | |
| 4857 | if (!data) { |
| 4858 | postDigestQueue.put(element, data = {}); |
| 4859 | postDigestElements.push(element); |
| 4860 | } |
| 4861 | |
| 4862 | if (add) { |
| 4863 | forEach(add.split(' '), function(className) { |
| 4864 | if (className) { |
| 4865 | data[className] = true; |
| 4866 | } |
| 4867 | }); |
| 4868 | } |
| 4869 | |
| 4870 | if (remove) { |
| 4871 | forEach(remove.split(' '), function(className) { |
| 4872 | if (className) { |
| 4873 | data[className] = false; |
| 4874 | } |
| 4875 | }); |
| 4876 | } |
| 4877 | |
| 4878 | if (postDigestElements.length > 1) return; |
| 4879 | |
| 4880 | $rootScope.$$postDigest(function() { |
| 4881 | forEach(postDigestElements, function(element) { |
| 4882 | var data = postDigestQueue.get(element); |
| 4883 | if (data) { |
| 4884 | var existing = splitClasses(element.attr('class')); |
| 4885 | var toAdd = ''; |
| 4886 | var toRemove = ''; |
| 4887 | forEach(data, function(status, className) { |
| 4888 | var hasClass = !!existing[className]; |
| 4889 | if (status !== hasClass) { |
| 4890 | if (status) { |
| 4891 | toAdd += (toAdd.length ? ' ' : '') + className; |
| 4892 | } else { |
| 4893 | toRemove += (toRemove.length ? ' ' : '') + className; |
| 4894 | } |
| 4895 | } |
| 4896 | }); |
| 4897 | |
| 4898 | forEach(element, function(elm) { |
| 4899 | toAdd && jqLiteAddClass(elm, toAdd); |
| 4900 | toRemove && jqLiteRemoveClass(elm, toRemove); |
| 4901 | }); |
| 4902 | postDigestQueue.remove(element); |
| 4903 | } |
| 4904 | }); |
| 4905 | |
| 4906 | postDigestElements.length = 0; |
| 4907 | }); |
| 4908 | } |
| 4909 | }]; |
| 4910 | }; |
no test coverage detected