Skip to content

Commit 015930d

Browse files
committed
fixed some jshint issues
1 parent 66400c0 commit 015930d

File tree

6 files changed

+51
-35
lines changed

6 files changed

+51
-35
lines changed

Gruntfile.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module.exports = function(grunt) {
22
'use strict';
33

44
var sourceFiles = [
5-
'*.js', '!Gruntfile.js'
5+
'*.js', '!Gruntfile.js',
6+
'!timing.js' // based on 3rd party script
67
];
78

89
grunt.initConfig({
@@ -20,7 +21,8 @@ module.exports = function(grunt) {
2021
jshint: {
2122
all: sourceFiles,
2223
options: {
23-
jshintrc: '.jshintrc'
24+
jshintrc: '.jshintrc',
25+
reporter: require('jshint-summary')
2426
}
2527
},
2628

ng-find-scope-property.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
// finds all properties with given name attached to the scopes
2-
function findScopeProperty(name) {
3-
var i, data, scope,
4-
all = document.all,
5-
len = all.length,
6-
test = {};
7-
var found = [];
2+
(function (window) {
83

9-
for (i=0; i < len; i++) {
10-
data = angular.element(all[i]).data();
11-
var scope = data.$scope || data.$isolateScope;
12-
if (scope && scope.hasOwnProperty(name)) {
13-
if ( ! test[ scope.$id ] ) {
14-
test[ scope.$id ] = true;
15-
found.push(scope);
4+
function findScopeProperty(name) {
5+
var i, data, scope,
6+
all = document.all,
7+
len = all.length,
8+
test = {};
9+
var found = [];
10+
11+
/* global angular */
12+
for (i=0; i < len; i++) {
13+
data = angular.element(all[i]).data();
14+
scope = data.$scope || data.$isolateScope;
15+
if (scope && scope.hasOwnProperty(name)) {
16+
if ( ! test[ scope.$id ] ) {
17+
test[ scope.$id ] = true;
18+
found.push(scope);
19+
}
1620
}
1721
}
22+
if (!found.length) {
23+
console.log('could not find any scopes with', name, 'property');
24+
} else {
25+
console.log('found', found.length, 'scopes with property', name);
26+
}
27+
return found;
1828
}
19-
if (!found.length) {
20-
console.log('could not find any scopes with', name, 'property');
21-
} else {
22-
console.log('found', found.length, 'scopes with property', name);
23-
}
24-
return found;
25-
}
29+
30+
window.findScopeProperty = findScopeProperty;
31+
}(window));

ng-idle-apply-timing.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// More watchers - longer cycle
33
// More complicated expression logic - longer cycle
44
// Also creates CPU profile for debugging bottlenecks (Chrome DevTools)
5+
6+
/* global angular, performance */
57
angular.element(document).injector().invoke(function timeApply($rootScope) {
68
console.profile('$apply');
79
var started = performance.now();

ng-profile-data-change.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
var propertyName = 'selectedBenchmarks';
88
var name = selector + ':' + propertyName;
99

10+
/* global angular */
1011
var el = angular.element(selector);
1112
var scope = el.scope() || el.isolateScope();
1213
console.assert(scope, 'cannot find scope from ' + name);
1314

1415
var property = scope[propertyName];
1516
console.assert(property, 'missing ' + name);
16-
var $timeout = el.injector().get('$timeout');
1717

1818
function digestCycle() {
1919
angular.element(document).injector().get('$rootScope').$apply();

ng-profile-local-digest.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@ dirty checking watchers) takes for a scope surrounding given selector.
33
Use: run this code snippet, then profileDirectiveDigest('#foo'); to measure
44
watchers in the #foo element (and its children along the scope tree).
55
*/
6-
function profileDirectiveDigest(selector) {
7-
console.assert(selector && typeof selector === 'string', 'expected selector', selector);
8-
var el = document.querySelector(selector);
9-
console.assert(el, 'cannot find element with selector', selector);
6+
(function (window) {
107

11-
/* global angular */
12-
var ngEl = angular.element(el);
13-
var scope = ngEl.scope() || ngEl.isolateScope();
14-
console.assert(scope, 'cannot find scope from element', selector);
15-
console.time(selector + ' digest');
16-
scope.$digest();
17-
console.timeEnd(selector + ' digest');
18-
}
8+
function profileDirectiveDigest(selector) {
9+
console.assert(selector && typeof selector === 'string', 'expected selector', selector);
10+
var el = document.querySelector(selector);
11+
console.assert(el, 'cannot find element with selector', selector);
12+
13+
/* global angular */
14+
var ngEl = angular.element(el);
15+
var scope = ngEl.scope() || ngEl.isolateScope();
16+
console.assert(scope, 'cannot find scope from element', selector);
17+
console.time(selector + ' digest');
18+
scope.$digest();
19+
console.timeEnd(selector + ' digest');
20+
}
21+
22+
window.profileDirectiveDigest = profileDirectiveDigest;
23+
}(window));

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"grunt-jscs": "1.0.0",
1919
"grunt-nice-package": "0.9.2",
2020
"grunt-npm2bower-sync": "0.4.0",
21+
"jshint-summary": "0.4.0",
2122
"matchdep": "0.3.0",
2223
"pre-git": "0.1.1"
2324
},

0 commit comments

Comments
 (0)