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

chore(Angular) Remove unused functions #9682

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@
"escapeForRegexp": false,
"isElement": false,
"makeMap": false,
"size": false,
"includes": false,
"arrayRemove": false,
"isLeafNode": false,
"copy": false,
"shallowCopy": false,
"equals": false,
Expand Down
42 changes: 0 additions & 42 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@
escapeForRegexp: true,
isElement: true,
makeMap: true,
size: true,
includes: true,
arrayRemove: true,
isLeafNode: true,
copy: true,
shallowCopy: true,
equals: true,
Expand Down Expand Up @@ -636,34 +634,6 @@ function nodeName_(element) {
return lowercase(element.nodeName || element[0].nodeName);
}


/**
* @description
* Determines the number of elements in an array, the number of properties an object has, or
* the length of a string.
*
* Note: This function is used to augment the Object type in Angular expressions. See
* {@link angular.Object} for more information about Angular arrays.
*
* @param {Object|Array|string} obj Object, array, or string to inspect.
* @param {boolean} [ownPropsOnly=false] Count only "own" properties in an object
* @returns {number} The size of `obj` or `0` if `obj` is neither an object nor an array.
*/
function size(obj, ownPropsOnly) {
var count = 0, key;

if (isArray(obj) || isString(obj)) {
return obj.length;
} else if (isObject(obj)) {
for (key in obj)
if (!ownPropsOnly || obj.hasOwnProperty(key))
count++;
}

return count;
}


function includes(array, obj) {
return Array.prototype.indexOf.call(array, obj) != -1;
}
Expand All @@ -675,18 +645,6 @@ function arrayRemove(array, value) {
return value;
}

function isLeafNode (node) {
if (node) {
switch (nodeName_(node)) {
case "option":
case "pre":
case "title":
return true;
}
}
return false;
}

/**
* @ngdoc function
* @name angular.copy
Expand Down
2 changes: 0 additions & 2 deletions test/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
"isPromiseLike": false,
"makeMap": false,
"map": false,
"size": false,
"includes": false,
"arrayRemove": false,
"isLeafNode": false,
"copy": false,
"shallowCopy": false,
"equals": false,
Expand Down
28 changes: 0 additions & 28 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,34 +392,6 @@ describe('angular', function() {
});
});

describe('size', function() {
it('should return the number of items in an array', function() {
expect(size([])).toBe(0);
expect(size(['a', 'b', 'c'])).toBe(3);
});

it('should return the number of properties of an object', function() {
expect(size({})).toBe(0);
expect(size({a:1, b:'a', c:noop})).toBe(3);
});

it('should return the number of own properties of an object', function() {
var obj = inherit({protoProp: 'c', protoFn: noop}, {a:1, b:'a', c:noop});

expect(size(obj)).toBe(5);
expect(size(obj, true)).toBe(3);
});

it('should return the string length', function() {
expect(size('')).toBe(0);
expect(size('abc')).toBe(3);
});

it('should not rely on length property of an object to determine its size', function() {
expect(size({length:99})).toBe(1);
});
});


describe('csp', function() {
var originalFunction;
Expand Down