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

Commit 52ee1ab

Browse files
committed
chore(*): remove dead code and fix code style issues
1 parent fcc556d commit 52ee1ab

23 files changed

+50
-130
lines changed

src/Angular.js

+16-60
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
////////////////////////////////////
44

5-
if (typeof document.getAttribute == $undefined)
5+
if (typeof document.getAttribute == 'undefined')
66
document.getAttribute = function() {};
77

88
/**
@@ -52,14 +52,7 @@ if ('i' !== 'I'.toLowerCase()) {
5252
function fromCharCode(code) {return String.fromCharCode(code);}
5353

5454

55-
var $boolean = 'boolean',
56-
$console = 'console',
57-
$length = 'length',
58-
$name = 'name',
59-
$object = 'object',
60-
$string = 'string',
61-
$undefined = 'undefined',
62-
Error = window.Error,
55+
var Error = window.Error,
6356
/** holds major version number for IE or NaN for real browsers */
6457
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]),
6558
jqLite, // delay binding since jQuery could be loaded after us.
@@ -107,7 +100,7 @@ function forEach(obj, iterator, context) {
107100
if (obj) {
108101
if (isFunction(obj)){
109102
for (key in obj) {
110-
if (key != 'prototype' && key != $length && key != $name && obj.hasOwnProperty(key)) {
103+
if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
111104
iterator.call(context, obj[key], key);
112105
}
113106
}
@@ -138,7 +131,7 @@ function sortedKeys(obj) {
138131
}
139132

140133
function forEachSorted(obj, iterator, context) {
141-
var keys = sortedKeys(obj)
134+
var keys = sortedKeys(obj);
142135
for ( var i = 0; i < keys.length; i++) {
143136
iterator.call(context, obj[keys[i]], keys[i]);
144137
}
@@ -269,7 +262,7 @@ function valueFn(value) {return function() {return value;};}
269262
* @param {*} value Reference to check.
270263
* @returns {boolean} True if `value` is undefined.
271264
*/
272-
function isUndefined(value){return typeof value == $undefined;}
265+
function isUndefined(value){return typeof value == 'undefined';}
273266

274267

275268
/**
@@ -283,7 +276,7 @@ function isUndefined(value){return typeof value == $undefined;}
283276
* @param {*} value Reference to check.
284277
* @returns {boolean} True if `value` is defined.
285278
*/
286-
function isDefined(value){return typeof value != $undefined;}
279+
function isDefined(value){return typeof value != 'undefined';}
287280

288281

289282
/**
@@ -298,7 +291,7 @@ function isDefined(value){return typeof value != $undefined;}
298291
* @param {*} value Reference to check.
299292
* @returns {boolean} True if `value` is an `Object` but not `null`.
300293
*/
301-
function isObject(value){return value!=null && typeof value == $object;}
294+
function isObject(value){return value != null && typeof value == 'object';}
302295

303296

304297
/**
@@ -312,7 +305,7 @@ function isObject(value){return value!=null && typeof value == $object;}
312305
* @param {*} value Reference to check.
313306
* @returns {boolean} True if `value` is a `String`.
314307
*/
315-
function isString(value){return typeof value == $string;}
308+
function isString(value){return typeof value == 'string';}
316309

317310

318311
/**
@@ -397,8 +390,10 @@ function isFile(obj) {
397390
}
398391

399392

400-
function isBoolean(value) {return typeof value == $boolean;}
401-
function isTextNode(node) {return nodeName_(node) == '#text';}
393+
function isBoolean(value) {
394+
return typeof value == 'boolean';
395+
}
396+
402397

403398
function trim(value) {
404399
return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value;
@@ -433,26 +428,6 @@ function makeMap(str){
433428
}
434429

435430

436-
437-
/**
438-
* HTML class which is the only class which can be used in ngBind to inline HTML for security
439-
* reasons.
440-
*
441-
* @constructor
442-
* @param html raw (unsafe) html
443-
* @param {string=} option If set to 'usafe', get method will return raw (unsafe/unsanitized) html
444-
*/
445-
function HTML(html, option) {
446-
this.html = html;
447-
this.get = lowercase(option) == 'unsafe'
448-
? valueFn(html)
449-
: function htmlSanitize() {
450-
var buf = [];
451-
htmlParser(html, htmlSanitizeWriter(buf));
452-
return buf.join('');
453-
};
454-
}
455-
456431
if (msie < 9) {
457432
nodeName_ = function(element) {
458433
element = element.nodeName ? element : element[0];
@@ -465,12 +440,6 @@ if (msie < 9) {
465440
};
466441
}
467442

468-
function isVisible(element) {
469-
var rect = element[0].getBoundingClientRect(),
470-
width = (rect.width || (rect.right||0 - rect.left||0)),
471-
height = (rect.height || (rect.bottom||0 - rect.top||0));
472-
return width>0 && height>0;
473-
}
474443

475444
function map(obj, iterator, context) {
476445
var results = [];
@@ -671,17 +640,6 @@ function equals(o1, o2) {
671640
return false;
672641
}
673642

674-
function setHtml(node, html) {
675-
if (isLeafNode(node)) {
676-
if (msie) {
677-
node.innerText = html;
678-
} else {
679-
node.textContent = html;
680-
}
681-
} else {
682-
node.innerHTML = html;
683-
}
684-
}
685643

686644
function concat(array1, array2, index) {
687645
return array1.concat(slice.call(array2, index));
@@ -742,7 +700,7 @@ function toJsonReplacer(key, value) {
742700
}
743701

744702
return val;
745-
};
703+
}
746704

747705

748706
/**
@@ -799,7 +757,7 @@ function startingTag(element) {
799757
// turns out IE does not let you set .html() on elements which
800758
// are not allowed to have children. So we just ignore it.
801759
element.html('');
802-
} catch(e) {};
760+
} catch(e) {}
803761
return jqLite('<div>').append(element).html().match(/^(<[^>]+>)/)[1];
804762
}
805763

@@ -918,7 +876,7 @@ function angularInit(element, bootstrap) {
918876
forEach(element.querySelectorAll('.' + name), append);
919877
forEach(element.querySelectorAll('.' + name + '\\:'), append);
920878
forEach(element.querySelectorAll('[' + name + ']'), append);
921-
};
879+
}
922880
});
923881

924882
forEach(elements, function(element) {
@@ -1005,9 +963,7 @@ function bindJQuery() {
1005963
*/
1006964
function assertArg(arg, name, reason) {
1007965
if (!arg) {
1008-
var error = new Error("Argument '" + (name||'?') + "' is " +
1009-
(reason || "required"));
1010-
throw error;
966+
throw new Error("Argument '" + (name || '?') + "' is " + (reason || "required"));
1011967
}
1012968
return arg;
1013969
}

src/AngularPublic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ function publishExternalAPI(angular){
130130
});
131131
}
132132
]);
133-
};
133+
}

src/angular-bootstrap.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
var filename = /^(.*\/)angular-bootstrap.js(#.*)?$/,
1111
scripts = document.getElementsByTagName("SCRIPT"),
12-
config,
1312
serverPath,
1413
match,
1514
globalVars = {};
@@ -84,7 +83,7 @@
8483
document.write('<script type="text/javascript" src="' + serverPath + file + '" ' +
8584
'onload="angularClobberTest(\'' + file + '\')"></script>');
8685
}
87-
}
86+
};
8887

8988
function addCss(file) {
9089
document.write('<link rel="stylesheet" type="text/css" href="' +

src/jqLite.js

+1-19
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,6 @@ var jqCache = {},
8787
function jqNextId() { return (jqId++); }
8888

8989

90-
function getStyle(element) {
91-
var current = {}, style = element[0].style, value, name, i;
92-
if (typeof style.length == 'number') {
93-
for(i = 0; i < style.length; i++) {
94-
name = style[i];
95-
current[name] = style[name];
96-
}
97-
} else {
98-
for (name in style) {
99-
value = style[name];
100-
if (1*name != name && name != 'cssText' && value && typeof value == 'string' && value !='false')
101-
current[name] = value;
102-
}
103-
}
104-
return current;
105-
}
106-
107-
10890
var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
10991
var MOZ_HACK_REGEXP = /^moz([A-Z])/;
11092

@@ -546,7 +528,7 @@ function createEventHandler(element) {
546528
};
547529
eventHandler.fns = [];
548530
return eventHandler;
549-
};
531+
}
550532

551533
//////////////////////////////////////////
552534
// Functions iterating traversal.

src/ng/browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function Browser(window, document, body, $log, $sniffer) {
249249
* @returns {Object} Hash of all cookies (if called without any parameter)
250250
*/
251251
self.cookies = function(name, value) {
252-
var cookieLength, cookieArray, cookie, i, keyValue, index;
252+
var cookieLength, cookieArray, cookie, i, index;
253253

254254
if (name) {
255255
if (value === undefined) {

src/ng/compiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ function $CompileProvider($provide) {
446446
if (isBooleanAttr(node, nName)) {
447447
attrs[nName] = true; // presence means true
448448
}
449-
addAttrInterpolateDirective(node, directives, value, nName)
449+
addAttrInterpolateDirective(node, directives, value, nName);
450450
addDirective(directives, nName, 'A', maxPriority);
451451
}
452452
}

src/ng/directive/booleanAttrs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
282282
ngAttributeAliasDirectives[normalized] = function() {
283283
return {
284284
priority: 100,
285-
compile: function(tpl, attr) {
285+
compile: function() {
286286
return function(scope, element, attr) {
287287
attr.$$observers[attrName] = [];
288288
scope.$watch(attr[normalized], function(value) {
@@ -301,7 +301,7 @@ forEach(['src', 'href'], function(attrName) {
301301
ngAttributeAliasDirectives[normalized] = function() {
302302
return {
303303
priority: 99, // it needs to run after the attributes are interpolated
304-
compile: function(tpl, attr) {
304+
compile: function() {
305305
return function(scope, element, attr) {
306306
var value = attr[normalized];
307307
if (value == undefined) {

src/ng/directive/directives.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ function ngDirective(directive) {
88
}
99
directive.restrict = directive.restrict || 'AC';
1010
return valueFn(directive);
11-
};
11+
}

src/ng/directive/form.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var nullFormCtrl = {
66
$removeControl: noop,
77
$setValidity: noop,
88
$setDirty: noop
9-
}
9+
};
1010

1111
/**
1212
* @ngdoc object

src/ng/directive/input.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
477477
ctrl.$parsers.push(maxLengthValidator);
478478
ctrl.$formatters.push(maxLengthValidator);
479479
}
480-
};
480+
}
481481

482482
function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
483483
textInputType(scope, element, attr, ctrl, $sniffer, $browser);
@@ -584,7 +584,7 @@ function radioInputType(scope, element, attr, ctrl) {
584584
scope.$apply(function() {
585585
ctrl.$setViewValue(attr.value);
586586
});
587-
};
587+
}
588588
});
589589

590590
ctrl.$render = function() {
@@ -840,7 +840,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', 'ngModel', '$e
840840
this.$invalid = false;
841841
}
842842
} else {
843-
toggleValidCss(false)
843+
toggleValidCss(false);
844844
this.$invalid = true;
845845
this.$valid = false;
846846
invalidCount++;

src/ng/directive/ngInclude.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
8282
onloadExp = attr.onload || '',
8383
autoScrollExp = attr.autoscroll;
8484

85-
return function(scope, element, attr) {
85+
return function(scope, element) {
8686
var changeCounter = 0,
8787
childScope;
8888

src/ng/directive/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
421421
while(optionGroupsCache.length > groupIndex) {
422422
optionGroupsCache.pop()[0].element.remove();
423423
}
424-
};
424+
}
425425
}
426426
}
427427
}

src/ng/filter/filters.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ function dateFilter($locale) {
344344
parts = [],
345345
fn, match;
346346

347-
format = format || 'mediumDate'
347+
format = format || 'mediumDate';
348348
format = $locale.DATETIME_FORMATS[format] || format;
349349
if (isString(date)) {
350350
if (NUMBER_STRING.test(date)) {
@@ -545,4 +545,4 @@ function linkyFilter() {
545545
writer.chars(raw);
546546
return html.join('');
547547
};
548-
};
548+
}

src/ng/httpBackend.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
108108
doneWrapper = function() {
109109
rawDocument.body.removeChild(script);
110110
if (done) done();
111-
}
111+
};
112112

113113
script.type = 'text/javascript';
114114
script.src = url;
@@ -122,5 +122,5 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
122122
}
123123

124124
rawDocument.body.appendChild(script);
125-
};
125+
}
126126
}

src/ng/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ function $LocationProvider(){
449449
} else {
450450
return hashPrefix;
451451
}
452-
}
452+
};
453453

454454
/**
455455
* @ngdoc property

0 commit comments

Comments
 (0)