From 0fc987b7e875d6a78bcda0cea97836d32e8c5015 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Sun, 19 Oct 2014 18:00:05 -0400 Subject: [PATCH 1/4] style(*): alphabetize jscs rules --- .jscs.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.jscs.json b/.jscs.json index c8f4a96b684c..a5444f7d348d 100644 --- a/.jscs.json +++ b/.jscs.json @@ -3,9 +3,9 @@ "disallowMixedSpacesAndTabs": true, "disallowMultipleLineStrings": true, "disallowNewlineBeforeBlockStatements": true, - "disallowTrailingWhitespace": true, + "disallowSpaceAfterObjectKeys": true, "disallowSpaceAfterPrefixUnaryOperators": ["!"], "disallowSpaceBeforeBinaryOperators": [","], - "disallowSpaceAfterObjectKeys": true, + "disallowTrailingWhitespace": true, "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"] } From 442d2517da8810199188a98147e166261b9932f9 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Sun, 19 Oct 2014 18:24:01 -0400 Subject: [PATCH 2/4] style(*): add disallowTrailingComma rule for objects and arrays --- .jscs.json | 1 + test/auto/injectorSpec.js | 4 ++-- test/loaderSpec.js | 2 +- test/ng/browserSpecs.js | 4 ++-- test/ng/compileSpec.js | 8 ++++---- test/ng/directive/selectSpec.js | 12 ++++++------ test/ng/rafSpec.js | 2 +- test/ngMessages/messagesSpec.js | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.jscs.json b/.jscs.json index a5444f7d348d..d8e4400baf02 100644 --- a/.jscs.json +++ b/.jscs.json @@ -6,6 +6,7 @@ "disallowSpaceAfterObjectKeys": true, "disallowSpaceAfterPrefixUnaryOperators": ["!"], "disallowSpaceBeforeBinaryOperators": [","], + "disallowTrailingComma": true, "disallowTrailingWhitespace": true, "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"] } diff --git a/test/auto/injectorSpec.js b/test/auto/injectorSpec.js index 1f6f18e1951b..e3ecab3bef78 100644 --- a/test/auto/injectorSpec.js +++ b/test/auto/injectorSpec.js @@ -960,7 +960,7 @@ describe('strict-di injector', function() { it('should throw if magic annotation is used by provider', function() { module(function($provide) { $provide.provider({ - '$test': function() { this.$get = function($rootScope) { return $rootScope; }; }, + '$test': function() { this.$get = function($rootScope) { return $rootScope; }; } }); }); inject(function($injector) { @@ -974,7 +974,7 @@ describe('strict-di injector', function() { it('should throw if magic annotation is used by factory', function() { module(function($provide) { $provide.factory({ - '$test': function($rootScope) { return function() {}; }, + '$test': function($rootScope) { return function() {}; } }); }); inject(function($injector) { diff --git a/test/loaderSpec.js b/test/loaderSpec.js index dbe637269780..8d7789ac9648 100644 --- a/test/loaderSpec.js +++ b/test/loaderSpec.js @@ -52,7 +52,7 @@ describe('module loader', function() { ['$provide', 'value', ['k', 'v'] ], ['$filterProvider', 'register', ['f', 'ff'] ], ['$compileProvider', 'directive', ['d', 'dd'] ], - ['$controllerProvider', 'register', ['ctrl', 'ccc']], + ['$controllerProvider', 'register', ['ctrl', 'ccc']] ]); expect(myModule._configBlocks).toEqual([ ['$injector', 'invoke', ['config'] ], diff --git a/test/ng/browserSpecs.js b/test/ng/browserSpecs.js index 99564ddefa1f..3548a5a2ba79 100755 --- a/test/ng/browserSpecs.js +++ b/test/ng/browserSpecs.js @@ -54,7 +54,7 @@ function MockWindow(options) { replace: function(url) { locationHref = url; mockWindow.history.state = null; - }, + } }; this.history = { @@ -81,7 +81,7 @@ function MockWindow(options) { ieState = value; }, configurable: true, - enumerable: true, + enumerable: true }); } } diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index fa758bca2d42..aeb24e0d02d4 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -295,7 +295,7 @@ describe('$compile', function() { directive('svgCircleUrl', valueFn({ replace: true, templateUrl: 'template.html', - templateNamespace: 'SVG', + templateNamespace: 'SVG' })); }); inject(function($compile, $rootScope, $httpBackend) { @@ -1058,7 +1058,7 @@ describe('$compile', function() { template: '{{pow}}', templateNamespace: 'MATH', scope: { - pow: '@pow', + pow: '@pow' }, link: function(scope, elm, attr, ctrl, transclude) { transclude(function(node) { @@ -1972,7 +1972,7 @@ describe('$compile', function() { templateUrl: 'template.html', templateNamespace: 'math', scope: { - pow: '@pow', + pow: '@pow' }, link: function(scope, elm, attr, ctrl, transclude) { transclude(function(node) { @@ -3185,7 +3185,7 @@ describe('$compile', function() { 'toString': '&', // Spidermonkey extension, may be obsolete in the future - 'watch': '=', + 'watch': '=' } })); }); diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 30ad415b8423..e4518f0b24ab 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -1988,7 +1988,7 @@ describe('select', function() { createSelect({ 'name': 'select', 'ng-model': 'value', - 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']', + 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']' }); scope.form.select.$parsers.push(function(value) { @@ -2005,7 +2005,7 @@ describe('select', function() { createSelect({ 'name': 'select', 'ng-model': 'value', - 'ng-options': 'item for item in [\'the first\', \'the second\', \'the third\', \'the fourth\']', + 'ng-options': 'item for item in [\'the first\', \'the second\', \'the third\', \'the fourth\']' }); scope.form.select.$formatters.push(function(value) { @@ -2022,7 +2022,7 @@ describe('select', function() { createSelect({ 'name': 'select', 'ng-model': 'value', - 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']', + 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']' }); scope.form.select.$validators.fail = function() { @@ -2040,7 +2040,7 @@ describe('select', function() { createSelect({ 'name': 'select', 'ng-model': 'value', - 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']', + 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']' }); scope.form.select.$validators.pass = function() { @@ -2059,7 +2059,7 @@ describe('select', function() { createSelect({ 'name': 'select', 'ng-model': 'value', - 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']', + 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']' }); scope.form.select.$asyncValidators.async = function() { @@ -2085,7 +2085,7 @@ describe('select', function() { createSelect({ 'name': 'select', 'ng-model': 'value', - 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']', + 'ng-options': 'item for item in [\'first\', \'second\', \'third\', \'fourth\']' }); scope.form.select.$asyncValidators.async = function() { diff --git a/test/ng/rafSpec.js b/test/ng/rafSpec.js index c16e002004c8..04ac6de211bc 100644 --- a/test/ng/rafSpec.js +++ b/test/ng/rafSpec.js @@ -39,7 +39,7 @@ describe('$$rAF', function() { var injector = createInjector(['ng', function($provide) { $provide.value('$timeout', timeoutSpy); $provide.value('$window', { - location: window.location, + location: window.location }); }]); diff --git a/test/ngMessages/messagesSpec.js b/test/ngMessages/messagesSpec.js index 3d73c7cfc091..a0b39ddf8570 100644 --- a/test/ngMessages/messagesSpec.js +++ b/test/ngMessages/messagesSpec.js @@ -361,7 +361,7 @@ describe('ngMessages', function() { $rootScope.$apply(function() { $rootScope.data = { 'a': 1, - 'b': 2, + 'b': 2 }; }); From 070e9fa926760633267c5b8dc446ed1513fdd0eb Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Sun, 19 Oct 2014 20:24:53 -0400 Subject: [PATCH 3/4] style(*): add validateParameterSeparator rule to jscs --- .jscs.json | 3 ++- src/ng/compile.js | 2 +- src/ng/filter/orderBy.js | 8 ++++---- src/ng/parse.js | 26 +++++++++++++------------- src/ngMock/angular-mocks.js | 6 +++--- test/ng/filter/filterSpec.js | 2 +- test/ng/intervalSpec.js | 4 ++-- test/ng/parseSpec.js | 4 ++-- 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.jscs.json b/.jscs.json index d8e4400baf02..771cea5e302a 100644 --- a/.jscs.json +++ b/.jscs.json @@ -8,5 +8,6 @@ "disallowSpaceBeforeBinaryOperators": [","], "disallowTrailingComma": true, "disallowTrailingWhitespace": true, - "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"] + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], + "validateParameterSeparator": ", " } diff --git a/src/ng/compile.js b/src/ng/compile.js index 9c21fe4a2e7f..afbe73127f60 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1870,7 +1870,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { if (parentGet.literal) { compare = equals; } else { - compare = function(a,b) { return a === b || (a !== a && b !== b); }; + compare = function(a, b) { return a === b || (a !== a && b !== b); }; } parentSet = parentGet.assign || function() { // reset the change, or we will throw this exception on every $digest diff --git a/src/ng/filter/orderBy.js b/src/ng/filter/orderBy.js index 32b438517f97..97e9ded562eb 100644 --- a/src/ng/filter/orderBy.js +++ b/src/ng/filter/orderBy.js @@ -130,19 +130,19 @@ function orderByFilter($parse){ } if ( predicate === '' ) { // Effectively no predicate was passed so we compare identity - return reverseComparator(function(a,b) { + return reverseComparator(function(a, b) { return compare(a, b); }, descending); } get = $parse(predicate); if (get.constant) { var key = get(); - return reverseComparator(function(a,b) { + return reverseComparator(function(a, b) { return compare(a[key], b[key]); }, descending); } } - return reverseComparator(function(a,b){ + return reverseComparator(function(a, b){ return compare(get(a),get(b)); }, descending); }); @@ -159,7 +159,7 @@ function orderByFilter($parse){ } function reverseComparator(comp, descending) { return descending - ? function(a,b){return comp(b,a);} + ? function(a, b){return comp(b,a);} : comp; } function compare(v1, v2){ diff --git a/src/ng/parse.js b/src/ng/parse.js index 5c562c5301b4..08392c7b19b4 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -99,7 +99,7 @@ CONSTANTS['this'].sharedGetter = true; //Operators - will be wrapped by binaryFn/unaryFn/assignment/filter var OPERATORS = extend(createMap(), { - '+':function(self, locals, a,b){ + '+':function(self, locals, a, b){ a=a(self, locals); b=b(self, locals); if (isDefined(a)) { if (isDefined(b)) { @@ -108,23 +108,23 @@ var OPERATORS = extend(createMap(), { return a; } return isDefined(b)?b:undefined;}, - '-':function(self, locals, a,b){ + '-':function(self, locals, a, b){ a=a(self, locals); b=b(self, locals); return (isDefined(a)?a:0)-(isDefined(b)?b:0); }, - '*':function(self, locals, a,b){return a(self, locals)*b(self, locals);}, - '/':function(self, locals, a,b){return a(self, locals)/b(self, locals);}, - '%':function(self, locals, a,b){return a(self, locals)%b(self, locals);}, + '*':function(self, locals, a, b){return a(self, locals)*b(self, locals);}, + '/':function(self, locals, a, b){return a(self, locals)/b(self, locals);}, + '%':function(self, locals, a, b){return a(self, locals)%b(self, locals);}, '===':function(self, locals, a, b){return a(self, locals)===b(self, locals);}, '!==':function(self, locals, a, b){return a(self, locals)!==b(self, locals);}, - '==':function(self, locals, a,b){return a(self, locals)==b(self, locals);}, - '!=':function(self, locals, a,b){return a(self, locals)!=b(self, locals);}, - '<':function(self, locals, a,b){return a(self, locals)':function(self, locals, a,b){return a(self, locals)>b(self, locals);}, - '<=':function(self, locals, a,b){return a(self, locals)<=b(self, locals);}, - '>=':function(self, locals, a,b){return a(self, locals)>=b(self, locals);}, - '&&':function(self, locals, a,b){return a(self, locals)&&b(self, locals);}, - '||':function(self, locals, a,b){return a(self, locals)||b(self, locals);}, + '==':function(self, locals, a, b){return a(self, locals)==b(self, locals);}, + '!=':function(self, locals, a, b){return a(self, locals)!=b(self, locals);}, + '<':function(self, locals, a, b){return a(self, locals)':function(self, locals, a, b){return a(self, locals)>b(self, locals);}, + '<=':function(self, locals, a, b){return a(self, locals)<=b(self, locals);}, + '>=':function(self, locals, a, b){return a(self, locals)>=b(self, locals);}, + '&&':function(self, locals, a, b){return a(self, locals)&&b(self, locals);}, + '||':function(self, locals, a, b){return a(self, locals)||b(self, locals);}, '!':function(self, locals, a){return !a(self, locals);}, //Tokenized as operators but parsed as assignment/filters diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 4a50c97f6732..90fb28536ea2 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -67,7 +67,7 @@ angular.mock.$Browser = function() { self.defer = function(fn, delay) { delay = delay || 0; self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId}); - self.deferredFns.sort(function(a,b){ return a.time - b.time;}); + self.deferredFns.sort(function(a, b){ return a.time - b.time;}); return self.deferredNextId++; }; @@ -497,7 +497,7 @@ angular.mock.$IntervalProvider = function() { id: nextRepeatId, deferred: deferred }); - repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;}); + repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;}); nextRepeatId++; return promise; @@ -546,7 +546,7 @@ angular.mock.$IntervalProvider = function() { var task = repeatFns[0]; task.fn(); task.nextTime += task.delay; - repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;}); + repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;}); } return millis; }; diff --git a/test/ng/filter/filterSpec.js b/test/ng/filter/filterSpec.js index 4249be8ef2c3..a76acc21fea9 100644 --- a/test/ng/filter/filterSpec.js +++ b/test/ng/filter/filterSpec.js @@ -160,7 +160,7 @@ describe('Filter: filter', function() { {key: 1, nonkey:14} ]; var expr = {key: 10}; - var comparator = function (obj,value) { + var comparator = function (obj, value) { return obj > value; }; expect(filter(items, expr, comparator)).toEqual([items[2]]); diff --git a/test/ng/intervalSpec.js b/test/ng/intervalSpec.js index 2ffa03309bdc..dd64d1b96f96 100644 --- a/test/ng/intervalSpec.js +++ b/test/ng/intervalSpec.js @@ -17,7 +17,7 @@ describe('$interval', function() { fn: fn, id: nextRepeatId }); - repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;}); + repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;}); return nextRepeatId++; }, @@ -43,7 +43,7 @@ describe('$interval', function() { var task = repeatFns[0]; task.fn(); task.nextTime += task.delay; - repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;}); + repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;}); } return millis; } diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js index c058b6500667..80c3c0716de5 100644 --- a/test/ng/parseSpec.js +++ b/test/ng/parseSpec.js @@ -463,12 +463,12 @@ describe('parser', function() { }); it('should evaluate function call without arguments', function() { - scope['const'] = function(a,b){return 123;}; + scope['const'] = function(a, b){return 123;}; expect(scope.$eval("const()")).toEqual(123); }); it('should evaluate function call with arguments', function() { - scope.add = function(a,b) { + scope.add = function(a, b) { return a+b; }; expect(scope.$eval("add(1,2)")).toEqual(3); From 209100379c92611bd28f79fa0dad6513db824f99 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Sun, 19 Oct 2014 21:12:23 -0400 Subject: [PATCH 4/4] style(*): add disallowSpacesInsideParentheses rule to jscs --- .jscs.json | 1 + src/Angular.js | 12 ++--- src/jqLite.js | 6 +-- src/ng/browser.js | 2 +- src/ng/compile.js | 10 ++-- src/ng/directive/select.js | 2 +- src/ng/filter/filter.js | 6 +-- src/ng/filter/filters.js | 2 +- src/ng/filter/orderBy.js | 6 +-- src/ng/interpolate.js | 4 +- src/ng/location.js | 14 ++--- src/ng/rootScope.js | 2 +- src/ngMock/angular-mocks.js | 2 +- src/ngRoute/directive/ngView.js | 2 +- src/ngSanitize/sanitize.js | 90 ++++++++++++++++---------------- src/ngTouch/directive/ngClick.js | 2 +- test/auto/injectorSpec.js | 4 +- test/helpers/matchers.js | 2 +- test/helpers/testabilityPatch.js | 4 +- test/jqLiteSpec.js | 4 +- test/ng/animateSpec.js | 4 +- test/ng/cacheFactorySpec.js | 2 +- test/ng/compileSpec.js | 6 +-- test/ng/controllerSpec.js | 2 +- test/ng/directive/scriptSpec.js | 2 +- test/ng/filter/filtersSpec.js | 2 +- test/ng/qSpec.js | 2 +- test/ngAnimate/animateSpec.js | 4 +- 28 files changed, 101 insertions(+), 100 deletions(-) diff --git a/.jscs.json b/.jscs.json index 771cea5e302a..290b342e8fd8 100644 --- a/.jscs.json +++ b/.jscs.json @@ -6,6 +6,7 @@ "disallowSpaceAfterObjectKeys": true, "disallowSpaceAfterPrefixUnaryOperators": ["!"], "disallowSpaceBeforeBinaryOperators": [","], + "disallowSpacesInsideParentheses": true, "disallowTrailingComma": true, "disallowTrailingWhitespace": true, "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], diff --git a/src/Angular.js b/src/Angular.js index 2728d7fc3cd3..363ff3266659 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -285,7 +285,7 @@ function sortedKeys(obj) { function forEachSorted(obj, iterator, context) { var keys = sortedKeys(obj); - for ( var i = 0; i < keys.length; i++) { + for (var i = 0; i < keys.length; i++) { iterator.call(context, obj[keys[i]], keys[i]); } return keys; @@ -626,7 +626,7 @@ function isElement(node) { */ function makeMap(str) { var obj = {}, items = str.split(","), i; - for ( i = 0; i < items.length; i++ ) + for (i = 0; i < items.length; i++) obj[ items[i] ] = true; return obj; } @@ -784,7 +784,7 @@ function copy(source, destination, stackSource, stackDest) { var result; if (isArray(source)) { destination.length = 0; - for ( var i = 0; i < source.length; i++) { + for (var i = 0; i < source.length; i++) { result = copy(source[i], null, stackSource, stackDest); if (isObject(source[i])) { stackSource.push(source[i]); @@ -801,7 +801,7 @@ function copy(source, destination, stackSource, stackDest) { delete destination[key]; }); } - for ( var key in source) { + for (var key in source) { if (source.hasOwnProperty(key)) { result = copy(source[key], null, stackSource, stackDest); if (isObject(source[key])) { @@ -1089,10 +1089,10 @@ function tryDecodeURIComponent(value) { function parseKeyValue(/**string*/keyValue) { var obj = {}, key_value, key; forEach((keyValue || "").split('&'), function(keyValue) { - if ( keyValue ) { + if (keyValue) { key_value = keyValue.replace(/\+/g,'%20').split('='); key = tryDecodeURIComponent(key_value[0]); - if ( isDefined(key) ) { + if (isDefined(key)) { var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true; if (!hasOwnProperty.call(obj, key)) { obj[key] = val; diff --git a/src/jqLite.js b/src/jqLite.js index 59be5d731877..b26904d0dc4f 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -358,7 +358,7 @@ function jqLiteData(element, key, value) { function jqLiteHasClass(element, selector) { if (!element.getAttribute) return false; return ((" " + (element.getAttribute('class') || '') + " ").replace(/[\n\t]/g, " "). - indexOf( " " + selector + " " ) > -1); + indexOf(" " + selector + " ") > -1); } function jqLiteRemoveClass(element, cssClasses) { @@ -417,7 +417,7 @@ function jqLiteAddNodes(root, elements) { function jqLiteController(element, name) { - return jqLiteInheritedData(element, '$' + (name || 'ngController' ) + 'Controller'); + return jqLiteInheritedData(element, '$' + (name || 'ngController') + 'Controller'); } function jqLiteInheritedData(element, name, value) { @@ -802,7 +802,7 @@ forEach({ var target = this, related = event.relatedTarget; // For mousenter/leave call the handler if related is outside the target. // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !target.contains(related)) ){ + if (!related || (related !== target && !target.contains(related))){ handle(event, type); } }); diff --git a/src/ng/browser.js b/src/ng/browser.js index c78aa410bd16..996695895845 100644 --- a/src/ng/browser.js +++ b/src/ng/browser.js @@ -451,7 +451,7 @@ function Browser(window, document, $log, $sniffer) { function $BrowserProvider(){ this.$get = ['$window', '$log', '$sniffer', '$document', - function( $window, $log, $sniffer, $document){ + function($window, $log, $sniffer, $document){ return new Browser($window, $document, $log, $sniffer); }]; } diff --git a/src/ng/compile.js b/src/ng/compile.js index afbe73127f60..b882b826388e 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1010,9 +1010,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { for (var i=0; i directive.priority) && + if ((maxPriority === undefined || maxPriority > directive.priority) && directive.restrict.indexOf(location) != -1) { if (startAttrName) { directive = inherit(directive, {$$start: startAttrName, $$end: endAttrName}); diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 2f3266b2a131..f6bed62cdc76 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -539,7 +539,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) { key = index; if (keyName) { key = keys[index]; - if ( key.charAt(0) === '$' ) continue; + if (key.charAt(0) === '$') continue; } value = values[key]; diff --git a/src/ng/filter/filter.js b/src/ng/filter/filter.js index 39cbe4d0789b..2882afb883c6 100644 --- a/src/ng/filter/filter.js +++ b/src/ng/filter/filter.js @@ -167,7 +167,7 @@ function filterFilter() { case 'object': return comparator(obj, text); default: - for ( var objKey in obj) { + for (var objKey in obj) { if (objKey.charAt(0) !== '$' && search(obj[objKey], text)) { return true; } @@ -176,7 +176,7 @@ function filterFilter() { } return false; case 'array': - for ( var i = 0; i < obj.length; i++) { + for (var i = 0; i < obj.length; i++) { if (search(obj[i], text)) { return true; } @@ -211,7 +211,7 @@ function filterFilter() { return array; } var filtered = []; - for ( var j = 0; j < array.length; j++) { + for (var j = 0; j < array.length; j++) { var value = array[j]; if (predicates.check(value, j)) { filtered.push(value); diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js index cf102ccd4bb2..0accbdeb06b3 100644 --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -240,7 +240,7 @@ function dateGetter(name, size, offset, trim) { var value = date['get' + name](); if (offset > 0 || value > -offset) value += offset; - if (value === 0 && offset == -12 ) value = 12; + if (value === 0 && offset == -12) value = 12; return padNumber(value, size, trim); }; } diff --git a/src/ng/filter/orderBy.js b/src/ng/filter/orderBy.js index 97e9ded562eb..3a1402ff7334 100644 --- a/src/ng/filter/orderBy.js +++ b/src/ng/filter/orderBy.js @@ -128,7 +128,7 @@ function orderByFilter($parse){ descending = predicate.charAt(0) == '-'; predicate = predicate.substring(1); } - if ( predicate === '' ) { + if (predicate === '') { // Effectively no predicate was passed so we compare identity return reverseComparator(function(a, b) { return compare(a, b); @@ -147,11 +147,11 @@ function orderByFilter($parse){ }, descending); }); var arrayCopy = []; - for ( var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); } + for (var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); } return arrayCopy.sort(reverseComparator(comparator, reverseOrder)); function comparator(o1, o2){ - for ( var i = 0; i < sortPredicate.length; i++) { + for (var i = 0; i < sortPredicate.length; i++) { var comp = sortPredicate[i](o1, o2); if (comp !== 0) return comp; } diff --git a/src/ng/interpolate.js b/src/ng/interpolate.js index 1d65975595cd..5f0b9eeb8d6b 100644 --- a/src/ng/interpolate.js +++ b/src/ng/interpolate.js @@ -195,8 +195,8 @@ function $InterpolateProvider() { expressionPositions = []; while (index < textLength) { - if ( ((startIndex = text.indexOf(startSymbol, index)) != -1) && - ((endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1) ) { + if (((startIndex = text.indexOf(startSymbol, index)) != -1) && + ((endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1)) { if (index !== startIndex) { concat.push(unescapeText(text.substring(index, startIndex))); } diff --git a/src/ng/location.js b/src/ng/location.js index b8ddebdd5972..8820f30f4ff2 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -137,14 +137,14 @@ function LocationHtml5Url(appBase, basePrefix) { var appUrl, prevAppUrl; var rewrittenUrl; - if ( (appUrl = beginsWith(appBase, url)) !== undefined ) { + if ((appUrl = beginsWith(appBase, url)) !== undefined) { prevAppUrl = appUrl; - if ( (appUrl = beginsWith(basePrefix, appUrl)) !== undefined ) { + if ((appUrl = beginsWith(basePrefix, appUrl)) !== undefined) { rewrittenUrl = appBaseNoFile + (beginsWith('/', appUrl) || appUrl); } else { rewrittenUrl = appBase + prevAppUrl; } - } else if ( (appUrl = beginsWith(appBaseNoFile, url)) !== undefined ) { + } else if ((appUrl = beginsWith(appBaseNoFile, url)) !== undefined) { rewrittenUrl = appBaseNoFile + appUrl; } else if (appBaseNoFile == url + '/') { rewrittenUrl = appBaseNoFile; @@ -278,11 +278,11 @@ function LocationHashbangInHtml5Url(appBase, hashPrefix) { var rewrittenUrl; var appUrl; - if ( appBase == stripHash(url) ) { + if (appBase == stripHash(url)) { rewrittenUrl = url; - } else if ( (appUrl = beginsWith(appBaseNoFile, url)) ) { + } else if ((appUrl = beginsWith(appBaseNoFile, url))) { rewrittenUrl = appBase + hashPrefix + appUrl; - } else if ( appBaseNoFile === url + '/') { + } else if (appBaseNoFile === url + '/') { rewrittenUrl = appBaseNoFile; } if (rewrittenUrl) { @@ -728,7 +728,7 @@ function $LocationProvider(){ */ this.$get = ['$rootScope', '$browser', '$sniffer', '$rootElement', - function( $rootScope, $browser, $sniffer, $rootElement) { + function($rootScope, $browser, $sniffer, $rootElement) { var $location, LocationMode, baseHref = $browser.baseHref(), // if base[href] is undefined, it defaults to '' diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index c46148819beb..fefe65e31a97 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -81,7 +81,7 @@ function $RootScopeProvider(){ }; this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser', - function( $injector, $exceptionHandler, $parse, $browser) { + function($injector, $exceptionHandler, $parse, $browser) { /** * @ngdoc type diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 90fb28536ea2..273ff637a9e3 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -876,7 +876,7 @@ angular.mock.dump = function(object) { function serializeScope(scope, offset) { offset = offset || ' '; var log = [offset + 'Scope(' + scope.$id + '): {']; - for ( var key in scope ) { + for (var key in scope) { if (Object.prototype.hasOwnProperty.call(scope, key) && !key.match(/^(\$|this)/)) { log.push(' ' + key + ': ' + angular.toJson(scope[key])); } diff --git a/src/ngRoute/directive/ngView.js b/src/ngRoute/directive/ngView.js index fcea135b626e..e4f6ad6edfad 100644 --- a/src/ngRoute/directive/ngView.js +++ b/src/ngRoute/directive/ngView.js @@ -179,7 +179,7 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory); * Emitted every time the ngView content is reloaded. */ ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate']; -function ngViewFactory( $route, $anchorScroll, $animate) { +function ngViewFactory($route, $anchorScroll, $animate) { return { restrict: 'ECA', terminal: true, diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index 5d7a6325af0c..49214d479aae 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -231,7 +231,7 @@ function makeMap(str) { * @param {string} html string * @param {object} handler */ -function htmlParser( html, handler ) { +function htmlParser(html, handler) { if (typeof html !== 'string') { if (html === null || typeof html === 'undefined') { html = ''; @@ -242,50 +242,50 @@ function htmlParser( html, handler ) { var index, chars, match, stack = [], last = html, text; stack.last = function() { return stack[ stack.length - 1 ]; }; - while ( html ) { + while (html) { text = ''; chars = true; // Make sure we're not in a script or style element - if ( !stack.last() || !specialElements[ stack.last() ] ) { + if (!stack.last() || !specialElements[ stack.last() ]) { // Comment - if ( html.indexOf("", index) === index) { - if (handler.comment) handler.comment( html.substring( 4, index ) ); - html = html.substring( index + 3 ); + if (index >= 0 && html.lastIndexOf("-->", index) === index) { + if (handler.comment) handler.comment(html.substring(4, index)); + html = html.substring(index + 3); chars = false; } // DOCTYPE - } else if ( DOCTYPE_REGEXP.test(html) ) { - match = html.match( DOCTYPE_REGEXP ); + } else if (DOCTYPE_REGEXP.test(html)) { + match = html.match(DOCTYPE_REGEXP); - if ( match ) { - html = html.replace( match[0], ''); + if (match) { + html = html.replace(match[0], ''); chars = false; } // end tag - } else if ( BEGING_END_TAGE_REGEXP.test(html) ) { - match = html.match( END_TAG_REGEXP ); + } else if (BEGING_END_TAGE_REGEXP.test(html)) { + match = html.match(END_TAG_REGEXP); - if ( match ) { - html = html.substring( match[0].length ); - match[0].replace( END_TAG_REGEXP, parseEndTag ); + if (match) { + html = html.substring(match[0].length); + match[0].replace(END_TAG_REGEXP, parseEndTag); chars = false; } // start tag - } else if ( BEGIN_TAG_REGEXP.test(html) ) { - match = html.match( START_TAG_REGEXP ); + } else if (BEGIN_TAG_REGEXP.test(html)) { + match = html.match(START_TAG_REGEXP); - if ( match ) { + if (match) { // We only have a valid start-tag if there is a '>'. - if ( match[4] ) { - html = html.substring( match[0].length ); - match[0].replace( START_TAG_REGEXP, parseStartTag ); + if (match[4]) { + html = html.substring(match[0].length); + match[0].replace(START_TAG_REGEXP, parseStartTag); } chars = false; } else { @@ -295,13 +295,13 @@ function htmlParser( html, handler ) { } } - if ( chars ) { + if (chars) { index = html.indexOf("<"); - text += index < 0 ? html : html.substring( 0, index ); - html = index < 0 ? "" : html.substring( index ); + text += index < 0 ? html : html.substring(0, index); + html = index < 0 ? "" : html.substring(index); - if (handler.chars) handler.chars( decodeEntities(text) ); + if (handler.chars) handler.chars(decodeEntities(text)); } } else { @@ -309,15 +309,15 @@ function htmlParser( html, handler ) { function(all, text){ text = text.replace(COMMENT_REGEXP, "$1").replace(CDATA_REGEXP, "$1"); - if (handler.chars) handler.chars( decodeEntities(text) ); + if (handler.chars) handler.chars(decodeEntities(text)); return ""; }); - parseEndTag( "", stack.last() ); + parseEndTag("", stack.last()); } - if ( html == last ) { + if (html == last) { throw $sanitizeMinErr('badparse', "The sanitizer was unable to parse the following block " + "of html: {0}", html); } @@ -327,22 +327,22 @@ function htmlParser( html, handler ) { // Clean up any remaining tags parseEndTag(); - function parseStartTag( tag, tagName, rest, unary ) { + function parseStartTag(tag, tagName, rest, unary) { tagName = angular.lowercase(tagName); - if ( blockElements[ tagName ] ) { - while ( stack.last() && inlineElements[ stack.last() ] ) { - parseEndTag( "", stack.last() ); + if (blockElements[ tagName ]) { + while (stack.last() && inlineElements[ stack.last() ]) { + parseEndTag("", stack.last()); } } - if ( optionalEndTagElements[ tagName ] && stack.last() == tagName ) { - parseEndTag( "", tagName ); + if (optionalEndTagElements[ tagName ] && stack.last() == tagName) { + parseEndTag("", tagName); } unary = voidElements[ tagName ] || !!unary; - if ( !unary ) - stack.push( tagName ); + if (!unary) + stack.push(tagName); var attrs = {}; @@ -355,22 +355,22 @@ function htmlParser( html, handler ) { attrs[name] = decodeEntities(value); }); - if (handler.start) handler.start( tagName, attrs, unary ); + if (handler.start) handler.start(tagName, attrs, unary); } - function parseEndTag( tag, tagName ) { + function parseEndTag(tag, tagName) { var pos = 0, i; tagName = angular.lowercase(tagName); - if ( tagName ) + if (tagName) // Find the closest opened tag of the same type - for ( pos = stack.length - 1; pos >= 0; pos-- ) - if ( stack[ pos ] == tagName ) + for (pos = stack.length - 1; pos >= 0; pos--) + if (stack[ pos ] == tagName) break; - if ( pos >= 0 ) { + if (pos >= 0) { // Close all the open elements, up the stack - for ( i = stack.length - 1; i >= pos; i-- ) - if (handler.end) handler.end( stack[ i ] ); + for (i = stack.length - 1; i >= pos; i--) + if (handler.end) handler.end(stack[ i ]); // Remove the open elements from the stack stack.length = pos; diff --git a/src/ngTouch/directive/ngClick.js b/src/ngTouch/directive/ngClick.js index eec652325b2d..2cb9f1c4198d 100644 --- a/src/ngTouch/directive/ngClick.js +++ b/src/ngTouch/directive/ngClick.js @@ -243,7 +243,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement', var e = touches[0].originalEvent || touches[0]; var x = e.clientX; var y = e.clientY; - var dist = Math.sqrt( Math.pow(x - touchStartX, 2) + Math.pow(y - touchStartY, 2) ); + var dist = Math.sqrt(Math.pow(x - touchStartX, 2) + Math.pow(y - touchStartY, 2)); if (tapping && diff < TAP_DURATION && dist < MOVE_TOLERANCE) { // Call preventGhostClick so the clickbuster will catch the corresponding click. diff --git a/test/auto/injectorSpec.js b/test/auto/injectorSpec.js index e3ecab3bef78..ff5dcc1f5654 100644 --- a/test/auto/injectorSpec.js +++ b/test/auto/injectorSpec.js @@ -195,7 +195,7 @@ describe('injector', function() { it('should handle no arg functions with spaces in the arguments list', function() { - function fn( ) {} + function fn() {} expect(annotate(fn)).toEqual([]); expect(fn.$inject).toEqual([]); }); @@ -264,7 +264,7 @@ describe('injector', function() { $provide.value('a', a); }, angular.extend(function(p, serviceA) { - p.value('b', serviceA.$get() + 'B' ); + p.value('b', serviceA.$get() + 'B'); }, {$inject:['$provide', 'aProvider']}), ['$provide', 'bProvider', function(p, serviceB) { p.value('c', serviceB.$get() + 'C'); diff --git a/test/helpers/matchers.js b/test/helpers/matchers.js index a73313e184e0..9bd3ba4a7d98 100644 --- a/test/helpers/matchers.js +++ b/test/helpers/matchers.js @@ -18,7 +18,7 @@ beforeEach(function() { this.message = function() { return "Expected to have " + presentClasses + - (absentClasses ? (" and not have " + absentClasses + "" ) : "") + + (absentClasses ? (" and not have " + absentClasses + "") : "") + " but had " + element[0].className + "."; }; return present && !absent; diff --git a/test/helpers/testabilityPatch.js b/test/helpers/testabilityPatch.js index 9b2b418aec3f..0020de85789f 100644 --- a/test/helpers/testabilityPatch.js +++ b/test/helpers/testabilityPatch.js @@ -87,7 +87,7 @@ afterEach(function() { function forEachSorted(obj, iterator, context) { var keys = sortedKeys(obj); - for ( var i = 0; i < keys.length; i++) { + for (var i = 0; i < keys.length; i++) { iterator.call(context, obj[keys[i]], keys[i]); } return keys; @@ -123,7 +123,7 @@ function dealoc(obj) { // element.contentWindow.document) and both properties are null for IFRAMES that aren't attached // to a document. var children = element[0].childNodes || []; - for ( var i = 0; i < children.length; i++) { + for (var i = 0; i < children.length; i++) { cleanup(angular.element(children[i])); } } diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index c57980f51229..c0b418886a8c 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -1199,7 +1199,7 @@ describe('jqLite', function() { }); // Only run this test for jqLite and not normal jQuery - if ( _jqLiteMode ) { + if (_jqLiteMode) { it('should throw an error if eventData or a selector is passed', function() { var elm = jqLite(a), anObj = {}, @@ -1484,7 +1484,7 @@ describe('jqLite', function() { // Only run this test for jqLite and not normal jQuery - if ( _jqLiteMode ) { + if (_jqLiteMode) { it('should throw an error if a selector is passed', function () { var aElem = jqLite(a); aElem.on('click', noop); diff --git a/test/ng/animateSpec.js b/test/ng/animateSpec.js index d89ed281c264..0c848ad1becd 100644 --- a/test/ng/animateSpec.js +++ b/test/ng/animateSpec.js @@ -200,13 +200,13 @@ describe("$animate", function() { var removeClassImmediately = $animate.$$removeClassImmediately; addClass = spyOn($animate, '$$addClassImmediately').andCallFake(function(element, classes) { var names = classes; - if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join( ' '); + if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join(' '); log('addClass(' + names + ')'); return addClassImmediately.call($animate, element, classes); }); removeClass = spyOn($animate, '$$removeClassImmediately').andCallFake(function(element, classes) { var names = classes; - if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join( ' '); + if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join(' '); log('removeClass(' + names + ')'); return removeClassImmediately.call($animate, element, classes); }); diff --git a/test/ng/cacheFactorySpec.js b/test/ng/cacheFactorySpec.js index c0d3c4808d9c..d704cf683e9a 100644 --- a/test/ng/cacheFactorySpec.js +++ b/test/ng/cacheFactorySpec.js @@ -164,7 +164,7 @@ describe('$cacheFactory', function() { cache.put('foo', 'bar'); cache.destroy(); - expect(function() { cache.get('foo'); } ).toThrow(); + expect(function() { cache.get('foo'); }).toThrow(); expect(function() { cache.get('neverexisted'); }).toThrow(); expect(function() { cache.put('foo', 'bar'); }).toThrow(); diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index aeb24e0d02d4..d2ed91ef0422 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2830,14 +2830,14 @@ describe('$compile', function() { directive('testLink', valueFn({ templateUrl: 'test-link.html', link: function(scope, element, attrs) { - attrs.$observe( 'testLink', function ( val ) { + attrs.$observe('testLink', function (val) { scope.testAttr = val; }); } })); }); inject(function($compile, $rootScope, $templateCache) { - $templateCache.put('test-link.html', '{{testAttr}}' ); + $templateCache.put('test-link.html', '{{testAttr}}'); element = $compile('
')($rootScope); $rootScope.$apply(); expect(element.text()).toBe('3'); @@ -6002,7 +6002,7 @@ describe('$compile', function() { 'http://example.com/image1.jpg?x=a2x,b 1x,http://example.com/ima,ge2.jpg 2x':'http://example.com/image1.jpg?x=a2x,b 1x,http://example.com/ima,ge2.jpg 2x' }; - forEach( testSet, function( ref, url) { + forEach(testSet, function(ref, url) { $rootScope.testUrl = url; $rootScope.$digest(); expect(element.attr('srcset')).toEqual(ref); diff --git a/test/ng/controllerSpec.js b/test/ng/controllerSpec.js index 0ef8efbbf1b8..b94f697cae07 100644 --- a/test/ng/controllerSpec.js +++ b/test/ng/controllerSpec.js @@ -34,7 +34,7 @@ describe('$controller', function() { scope = {}, ctrl; - $controllerProvider.register({FooCtrl: FooCtrl, BarCtrl: BarCtrl} ); + $controllerProvider.register({FooCtrl: FooCtrl, BarCtrl: BarCtrl}); ctrl = $controller('FooCtrl', {$scope: scope}); expect(scope.foo).toBe('foo'); diff --git a/test/ng/directive/scriptSpec.js b/test/ng/directive/scriptSpec.js index 73128765a9a2..0358c02f3608 100644 --- a/test/ng/directive/scriptSpec.js +++ b/test/ng/directive/scriptSpec.js @@ -14,7 +14,7 @@ describe('scriptDirective', function() { $compile('
foo' + '' + '' + - '
' ); + ''); expect($templateCache.get('/myTemplate.html')).toBe('{{y}}'); expect($templateCache.get('/ignore')).toBeUndefined(); } diff --git a/test/ng/filter/filtersSpec.js b/test/ng/filter/filtersSpec.js index f943e5fa6f75..5a376651047e 100644 --- a/test/ng/filter/filtersSpec.js +++ b/test/ng/filter/filtersSpec.js @@ -291,7 +291,7 @@ describe('filters', function() { it('should format timezones correctly (as per ISO_8601)', function() { //Note: TzDate's first argument is offset, _not_ timezone. - var utc = new angular.mock.TzDate( 0, '2010-09-03T12:05:08.000Z'); + var utc = new angular.mock.TzDate(0, '2010-09-03T12:05:08.000Z'); var eastOfUTC = new angular.mock.TzDate(-5, '2010-09-03T12:05:08.000Z'); var westOfUTC = new angular.mock.TzDate(+5, '2010-09-03T12:05:08.000Z'); var eastOfUTCPartial = new angular.mock.TzDate(-5.5, '2010-09-03T12:05:08.000Z'); diff --git a/test/ng/qSpec.js b/test/ng/qSpec.js index 74251475366c..75ea02c52c39 100644 --- a/test/ng/qSpec.js +++ b/test/ng/qSpec.js @@ -171,7 +171,7 @@ describe('q', function() { try { task(); } catch (e) { - if ( mockNextTick.logExceptions ) { + if (mockNextTick.logExceptions) { dump('exception in mockNextTick:', e, e.name, e.message, task); } } diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 2f4faf72c074..33c64bed2df5 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -5384,13 +5384,13 @@ describe("ngAnimate", function() { var removeClassImmediately = $originalAnimate.$$removeClassImmediately; addClass = spyOn($originalAnimate, '$$addClassImmediately').andCallFake(function(element, classes) { var names = classes; - if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join( ' '); + if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join(' '); log('addClass(' + names + ')'); return addClassImmediately.call($originalAnimate, element, classes); }); removeClass = spyOn($originalAnimate, '$$removeClassImmediately').andCallFake(function(element, classes) { var names = classes; - if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join( ' '); + if (Object.prototype.toString.call(classes) === '[object Array]') names = classes.join(' '); log('removeClass(' + names + ')'); return removeClassImmediately.call($originalAnimate, element, classes); });