Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ba9d073

Browse files
realitykingpetebacondarwin
authored andcommitted
refact(Angular.js) remove unused functions
This removes the functions size() and isLeafNode(). Closes #9682
1 parent 998c61c commit ba9d073

File tree

4 files changed

+0
-74
lines changed

4 files changed

+0
-74
lines changed

src/.jshintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@
5757
"escapeForRegexp": false,
5858
"isElement": false,
5959
"makeMap": false,
60-
"size": false,
6160
"includes": false,
6261
"arrayRemove": false,
63-
"isLeafNode": false,
6462
"copy": false,
6563
"shallowCopy": false,
6664
"equals": false,

src/Angular.js

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@
5252
escapeForRegexp: true,
5353
isElement: true,
5454
makeMap: true,
55-
size: true,
5655
includes: true,
5756
arrayRemove: true,
58-
isLeafNode: true,
5957
copy: true,
6058
shallowCopy: true,
6159
equals: true,
@@ -636,34 +634,6 @@ function nodeName_(element) {
636634
return lowercase(element.nodeName || element[0].nodeName);
637635
}
638636

639-
640-
/**
641-
* @description
642-
* Determines the number of elements in an array, the number of properties an object has, or
643-
* the length of a string.
644-
*
645-
* Note: This function is used to augment the Object type in Angular expressions. See
646-
* {@link angular.Object} for more information about Angular arrays.
647-
*
648-
* @param {Object|Array|string} obj Object, array, or string to inspect.
649-
* @param {boolean} [ownPropsOnly=false] Count only "own" properties in an object
650-
* @returns {number} The size of `obj` or `0` if `obj` is neither an object nor an array.
651-
*/
652-
function size(obj, ownPropsOnly) {
653-
var count = 0, key;
654-
655-
if (isArray(obj) || isString(obj)) {
656-
return obj.length;
657-
} else if (isObject(obj)) {
658-
for (key in obj)
659-
if (!ownPropsOnly || obj.hasOwnProperty(key))
660-
count++;
661-
}
662-
663-
return count;
664-
}
665-
666-
667637
function includes(array, obj) {
668638
return Array.prototype.indexOf.call(array, obj) != -1;
669639
}
@@ -675,18 +645,6 @@ function arrayRemove(array, value) {
675645
return value;
676646
}
677647

678-
function isLeafNode (node) {
679-
if (node) {
680-
switch (nodeName_(node)) {
681-
case "option":
682-
case "pre":
683-
case "title":
684-
return true;
685-
}
686-
}
687-
return false;
688-
}
689-
690648
/**
691649
* @ngdoc function
692650
* @name angular.copy

test/.jshintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@
5454
"isPromiseLike": false,
5555
"makeMap": false,
5656
"map": false,
57-
"size": false,
5857
"includes": false,
5958
"arrayRemove": false,
60-
"isLeafNode": false,
6159
"copy": false,
6260
"shallowCopy": false,
6361
"equals": false,

test/AngularSpec.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -392,34 +392,6 @@ describe('angular', function() {
392392
});
393393
});
394394

395-
describe('size', function() {
396-
it('should return the number of items in an array', function() {
397-
expect(size([])).toBe(0);
398-
expect(size(['a', 'b', 'c'])).toBe(3);
399-
});
400-
401-
it('should return the number of properties of an object', function() {
402-
expect(size({})).toBe(0);
403-
expect(size({a:1, b:'a', c:noop})).toBe(3);
404-
});
405-
406-
it('should return the number of own properties of an object', function() {
407-
var obj = inherit({protoProp: 'c', protoFn: noop}, {a:1, b:'a', c:noop});
408-
409-
expect(size(obj)).toBe(5);
410-
expect(size(obj, true)).toBe(3);
411-
});
412-
413-
it('should return the string length', function() {
414-
expect(size('')).toBe(0);
415-
expect(size('abc')).toBe(3);
416-
});
417-
418-
it('should not rely on length property of an object to determine its size', function() {
419-
expect(size({length:99})).toBe(1);
420-
});
421-
});
422-
423395

424396
describe('csp', function() {
425397
var originalFunction;

0 commit comments

Comments
 (0)