From c7eea6952e75d8bc4cb76e239c831da6e336300a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rouven=20We=C3=9Fling?= Date: Mon, 20 Oct 2014 00:40:31 +0200 Subject: [PATCH] chore(Angular) Remove unused functions This removes the functions size() and isLeafNode(). --- src/.jshintrc | 2 -- src/Angular.js | 42 ------------------------------------------ test/.jshintrc | 2 -- test/AngularSpec.js | 28 ---------------------------- 4 files changed, 74 deletions(-) diff --git a/src/.jshintrc b/src/.jshintrc index 1c5c0e0b246e..5e364938ef68 100644 --- a/src/.jshintrc +++ b/src/.jshintrc @@ -57,10 +57,8 @@ "escapeForRegexp": false, "isElement": false, "makeMap": false, - "size": false, "includes": false, "arrayRemove": false, - "isLeafNode": false, "copy": false, "shallowCopy": false, "equals": false, diff --git a/src/Angular.js b/src/Angular.js index 2728d7fc3cd3..924b5ff1ea81 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -52,10 +52,8 @@ escapeForRegexp: true, isElement: true, makeMap: true, - size: true, includes: true, arrayRemove: true, - isLeafNode: true, copy: true, shallowCopy: true, equals: true, @@ -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; } @@ -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 diff --git a/test/.jshintrc b/test/.jshintrc index 811d07752908..f767bd2220f7 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -54,10 +54,8 @@ "isPromiseLike": false, "makeMap": false, "map": false, - "size": false, "includes": false, "arrayRemove": false, - "isLeafNode": false, "copy": false, "shallowCopy": false, "equals": false, diff --git a/test/AngularSpec.js b/test/AngularSpec.js index adc8b08bcdc9..19d2d71c8195 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -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;