mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
chore(*): remove dead code and fix code style issues
This commit is contained in:
parent
fcc556df37
commit
52ee1ab5eb
23 changed files with 50 additions and 130 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
////////////////////////////////////
|
||||
|
||||
if (typeof document.getAttribute == $undefined)
|
||||
if (typeof document.getAttribute == 'undefined')
|
||||
document.getAttribute = function() {};
|
||||
|
||||
/**
|
||||
|
|
@ -52,14 +52,7 @@ if ('i' !== 'I'.toLowerCase()) {
|
|||
function fromCharCode(code) {return String.fromCharCode(code);}
|
||||
|
||||
|
||||
var $boolean = 'boolean',
|
||||
$console = 'console',
|
||||
$length = 'length',
|
||||
$name = 'name',
|
||||
$object = 'object',
|
||||
$string = 'string',
|
||||
$undefined = 'undefined',
|
||||
Error = window.Error,
|
||||
var Error = window.Error,
|
||||
/** holds major version number for IE or NaN for real browsers */
|
||||
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]),
|
||||
jqLite, // delay binding since jQuery could be loaded after us.
|
||||
|
|
@ -107,7 +100,7 @@ function forEach(obj, iterator, context) {
|
|||
if (obj) {
|
||||
if (isFunction(obj)){
|
||||
for (key in obj) {
|
||||
if (key != 'prototype' && key != $length && key != $name && obj.hasOwnProperty(key)) {
|
||||
if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
|
||||
iterator.call(context, obj[key], key);
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +131,7 @@ function sortedKeys(obj) {
|
|||
}
|
||||
|
||||
function forEachSorted(obj, iterator, context) {
|
||||
var keys = sortedKeys(obj)
|
||||
var keys = sortedKeys(obj);
|
||||
for ( var i = 0; i < keys.length; i++) {
|
||||
iterator.call(context, obj[keys[i]], keys[i]);
|
||||
}
|
||||
|
|
@ -269,7 +262,7 @@ function valueFn(value) {return function() {return value;};}
|
|||
* @param {*} value Reference to check.
|
||||
* @returns {boolean} True if `value` is undefined.
|
||||
*/
|
||||
function isUndefined(value){return typeof value == $undefined;}
|
||||
function isUndefined(value){return typeof value == 'undefined';}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -283,7 +276,7 @@ function isUndefined(value){return typeof value == $undefined;}
|
|||
* @param {*} value Reference to check.
|
||||
* @returns {boolean} True if `value` is defined.
|
||||
*/
|
||||
function isDefined(value){return typeof value != $undefined;}
|
||||
function isDefined(value){return typeof value != 'undefined';}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -298,7 +291,7 @@ function isDefined(value){return typeof value != $undefined;}
|
|||
* @param {*} value Reference to check.
|
||||
* @returns {boolean} True if `value` is an `Object` but not `null`.
|
||||
*/
|
||||
function isObject(value){return value!=null && typeof value == $object;}
|
||||
function isObject(value){return value != null && typeof value == 'object';}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -312,7 +305,7 @@ function isObject(value){return value!=null && typeof value == $object;}
|
|||
* @param {*} value Reference to check.
|
||||
* @returns {boolean} True if `value` is a `String`.
|
||||
*/
|
||||
function isString(value){return typeof value == $string;}
|
||||
function isString(value){return typeof value == 'string';}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -397,8 +390,10 @@ function isFile(obj) {
|
|||
}
|
||||
|
||||
|
||||
function isBoolean(value) {return typeof value == $boolean;}
|
||||
function isTextNode(node) {return nodeName_(node) == '#text';}
|
||||
function isBoolean(value) {
|
||||
return typeof value == 'boolean';
|
||||
}
|
||||
|
||||
|
||||
function trim(value) {
|
||||
return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value;
|
||||
|
|
@ -433,26 +428,6 @@ function makeMap(str){
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* HTML class which is the only class which can be used in ngBind to inline HTML for security
|
||||
* reasons.
|
||||
*
|
||||
* @constructor
|
||||
* @param html raw (unsafe) html
|
||||
* @param {string=} option If set to 'usafe', get method will return raw (unsafe/unsanitized) html
|
||||
*/
|
||||
function HTML(html, option) {
|
||||
this.html = html;
|
||||
this.get = lowercase(option) == 'unsafe'
|
||||
? valueFn(html)
|
||||
: function htmlSanitize() {
|
||||
var buf = [];
|
||||
htmlParser(html, htmlSanitizeWriter(buf));
|
||||
return buf.join('');
|
||||
};
|
||||
}
|
||||
|
||||
if (msie < 9) {
|
||||
nodeName_ = function(element) {
|
||||
element = element.nodeName ? element : element[0];
|
||||
|
|
@ -465,12 +440,6 @@ if (msie < 9) {
|
|||
};
|
||||
}
|
||||
|
||||
function isVisible(element) {
|
||||
var rect = element[0].getBoundingClientRect(),
|
||||
width = (rect.width || (rect.right||0 - rect.left||0)),
|
||||
height = (rect.height || (rect.bottom||0 - rect.top||0));
|
||||
return width>0 && height>0;
|
||||
}
|
||||
|
||||
function map(obj, iterator, context) {
|
||||
var results = [];
|
||||
|
|
@ -671,17 +640,6 @@ function equals(o1, o2) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function setHtml(node, html) {
|
||||
if (isLeafNode(node)) {
|
||||
if (msie) {
|
||||
node.innerText = html;
|
||||
} else {
|
||||
node.textContent = html;
|
||||
}
|
||||
} else {
|
||||
node.innerHTML = html;
|
||||
}
|
||||
}
|
||||
|
||||
function concat(array1, array2, index) {
|
||||
return array1.concat(slice.call(array2, index));
|
||||
|
|
@ -742,7 +700,7 @@ function toJsonReplacer(key, value) {
|
|||
}
|
||||
|
||||
return val;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -799,7 +757,7 @@ function startingTag(element) {
|
|||
// turns out IE does not let you set .html() on elements which
|
||||
// are not allowed to have children. So we just ignore it.
|
||||
element.html('');
|
||||
} catch(e) {};
|
||||
} catch(e) {}
|
||||
return jqLite('<div>').append(element).html().match(/^(<[^>]+>)/)[1];
|
||||
}
|
||||
|
||||
|
|
@ -918,7 +876,7 @@ function angularInit(element, bootstrap) {
|
|||
forEach(element.querySelectorAll('.' + name), append);
|
||||
forEach(element.querySelectorAll('.' + name + '\\:'), append);
|
||||
forEach(element.querySelectorAll('[' + name + ']'), append);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
forEach(elements, function(element) {
|
||||
|
|
@ -1005,9 +963,7 @@ function bindJQuery() {
|
|||
*/
|
||||
function assertArg(arg, name, reason) {
|
||||
if (!arg) {
|
||||
var error = new Error("Argument '" + (name||'?') + "' is " +
|
||||
(reason || "required"));
|
||||
throw error;
|
||||
throw new Error("Argument '" + (name || '?') + "' is " + (reason || "required"));
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,4 +130,4 @@ function publishExternalAPI(angular){
|
|||
});
|
||||
}
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
3
src/angular-bootstrap.js
vendored
3
src/angular-bootstrap.js
vendored
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
var filename = /^(.*\/)angular-bootstrap.js(#.*)?$/,
|
||||
scripts = document.getElementsByTagName("SCRIPT"),
|
||||
config,
|
||||
serverPath,
|
||||
match,
|
||||
globalVars = {};
|
||||
|
|
@ -84,7 +83,7 @@
|
|||
document.write('<script type="text/javascript" src="' + serverPath + file + '" ' +
|
||||
'onload="angularClobberTest(\'' + file + '\')"></script>');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function addCss(file) {
|
||||
document.write('<link rel="stylesheet" type="text/css" href="' +
|
||||
|
|
|
|||
|
|
@ -87,24 +87,6 @@ var jqCache = {},
|
|||
function jqNextId() { return (jqId++); }
|
||||
|
||||
|
||||
function getStyle(element) {
|
||||
var current = {}, style = element[0].style, value, name, i;
|
||||
if (typeof style.length == 'number') {
|
||||
for(i = 0; i < style.length; i++) {
|
||||
name = style[i];
|
||||
current[name] = style[name];
|
||||
}
|
||||
} else {
|
||||
for (name in style) {
|
||||
value = style[name];
|
||||
if (1*name != name && name != 'cssText' && value && typeof value == 'string' && value !='false')
|
||||
current[name] = value;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
|
||||
var MOZ_HACK_REGEXP = /^moz([A-Z])/;
|
||||
|
||||
|
|
@ -546,7 +528,7 @@ function createEventHandler(element) {
|
|||
};
|
||||
eventHandler.fns = [];
|
||||
return eventHandler;
|
||||
};
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Functions iterating traversal.
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ function Browser(window, document, body, $log, $sniffer) {
|
|||
* @returns {Object} Hash of all cookies (if called without any parameter)
|
||||
*/
|
||||
self.cookies = function(name, value) {
|
||||
var cookieLength, cookieArray, cookie, i, keyValue, index;
|
||||
var cookieLength, cookieArray, cookie, i, index;
|
||||
|
||||
if (name) {
|
||||
if (value === undefined) {
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ function $CompileProvider($provide) {
|
|||
if (isBooleanAttr(node, nName)) {
|
||||
attrs[nName] = true; // presence means true
|
||||
}
|
||||
addAttrInterpolateDirective(node, directives, value, nName)
|
||||
addAttrInterpolateDirective(node, directives, value, nName);
|
||||
addDirective(directives, nName, 'A', maxPriority);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
|
|||
ngAttributeAliasDirectives[normalized] = function() {
|
||||
return {
|
||||
priority: 100,
|
||||
compile: function(tpl, attr) {
|
||||
compile: function() {
|
||||
return function(scope, element, attr) {
|
||||
attr.$$observers[attrName] = [];
|
||||
scope.$watch(attr[normalized], function(value) {
|
||||
|
|
@ -301,7 +301,7 @@ forEach(['src', 'href'], function(attrName) {
|
|||
ngAttributeAliasDirectives[normalized] = function() {
|
||||
return {
|
||||
priority: 99, // it needs to run after the attributes are interpolated
|
||||
compile: function(tpl, attr) {
|
||||
compile: function() {
|
||||
return function(scope, element, attr) {
|
||||
var value = attr[normalized];
|
||||
if (value == undefined) {
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ function ngDirective(directive) {
|
|||
}
|
||||
directive.restrict = directive.restrict || 'AC';
|
||||
return valueFn(directive);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ var nullFormCtrl = {
|
|||
$removeControl: noop,
|
||||
$setValidity: noop,
|
||||
$setDirty: noop
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc object
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
|
|||
ctrl.$parsers.push(maxLengthValidator);
|
||||
ctrl.$formatters.push(maxLengthValidator);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
|
||||
textInputType(scope, element, attr, ctrl, $sniffer, $browser);
|
||||
|
|
@ -584,7 +584,7 @@ function radioInputType(scope, element, attr, ctrl) {
|
|||
scope.$apply(function() {
|
||||
ctrl.$setViewValue(attr.value);
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
ctrl.$render = function() {
|
||||
|
|
@ -840,7 +840,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', 'ngModel', '$e
|
|||
this.$invalid = false;
|
||||
}
|
||||
} else {
|
||||
toggleValidCss(false)
|
||||
toggleValidCss(false);
|
||||
this.$invalid = true;
|
||||
this.$valid = false;
|
||||
invalidCount++;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
|
|||
onloadExp = attr.onload || '',
|
||||
autoScrollExp = attr.autoscroll;
|
||||
|
||||
return function(scope, element, attr) {
|
||||
return function(scope, element) {
|
||||
var changeCounter = 0,
|
||||
childScope;
|
||||
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
|||
while(optionGroupsCache.length > groupIndex) {
|
||||
optionGroupsCache.pop()[0].element.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ function dateFilter($locale) {
|
|||
parts = [],
|
||||
fn, match;
|
||||
|
||||
format = format || 'mediumDate'
|
||||
format = format || 'mediumDate';
|
||||
format = $locale.DATETIME_FORMATS[format] || format;
|
||||
if (isString(date)) {
|
||||
if (NUMBER_STRING.test(date)) {
|
||||
|
|
@ -545,4 +545,4 @@ function linkyFilter() {
|
|||
writer.chars(raw);
|
||||
return html.join('');
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
|
|||
doneWrapper = function() {
|
||||
rawDocument.body.removeChild(script);
|
||||
if (done) done();
|
||||
}
|
||||
};
|
||||
|
||||
script.type = 'text/javascript';
|
||||
script.src = url;
|
||||
|
|
@ -122,5 +122,5 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
|
|||
}
|
||||
|
||||
rawDocument.body.appendChild(script);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ function $LocationProvider(){
|
|||
} else {
|
||||
return hashPrefix;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc property
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ function lex(text){
|
|||
|
||||
//check if this is not a method invocation and if it is back out to last dot
|
||||
if (lastDot) {
|
||||
peekIndex = index
|
||||
peekIndex = index;
|
||||
while(peekIndex < text.length) {
|
||||
var ch = text.charAt(peekIndex);
|
||||
if (ch == '(') {
|
||||
|
|
@ -269,7 +269,8 @@ function parser(text, json, $filter){
|
|||
functionCall = _functionCall,
|
||||
fieldAccess = _fieldAccess,
|
||||
objectIndex = _objectIndex,
|
||||
filterChain = _filterChain
|
||||
filterChain = _filterChain;
|
||||
|
||||
if(json){
|
||||
// The extra level of aliasing is here, just in case the lexer misses something, so that
|
||||
// we prevent any accidental execution in JSON.
|
||||
|
|
@ -344,10 +345,6 @@ function parser(text, json, $filter){
|
|||
};
|
||||
}
|
||||
|
||||
function hasTokens () {
|
||||
return tokens.length > 0;
|
||||
}
|
||||
|
||||
function statements() {
|
||||
var statements = [];
|
||||
while(true) {
|
||||
|
|
@ -497,21 +494,6 @@ function parser(text, json, $filter){
|
|||
}
|
||||
}
|
||||
|
||||
function _functionIdent(fnScope) {
|
||||
var token = expect();
|
||||
var element = token.text.split('.');
|
||||
var instance = fnScope;
|
||||
var key;
|
||||
for ( var i = 0; i < element.length; i++) {
|
||||
key = element[i];
|
||||
if (instance)
|
||||
instance = instance[key];
|
||||
}
|
||||
if (!isFunction(instance)) {
|
||||
throwError("should be a function", token);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
function primary() {
|
||||
var primary;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ function $RootScopeProvider(){
|
|||
TTL = value;
|
||||
}
|
||||
return TTL;
|
||||
}
|
||||
};
|
||||
|
||||
this.$get = ['$injector', '$exceptionHandler', '$parse',
|
||||
function( $injector, $exceptionHandler, $parse) {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ function $SanitizeProvider() {
|
|||
htmlParser(html, htmlSanitizeWriter(buf));
|
||||
return buf.join('');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Regular Expressions for parsing tags and attributes
|
||||
var START_TAG_REGEXP = /^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,
|
||||
|
|
|
|||
9
src/ngMock/angular-mocks.js
vendored
9
src/ngMock/angular-mocks.js
vendored
|
|
@ -241,13 +241,15 @@ angular.mock.$ExceptionHandlerProvider = function() {
|
|||
break;
|
||||
case 'log':
|
||||
var errors = [];
|
||||
|
||||
handler = function(e) {
|
||||
if (arguments.length == 1) {
|
||||
errors.push(e);
|
||||
} else {
|
||||
errors.push([].slice.call(arguments, 0));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
handler.errors = errors;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -445,7 +447,7 @@ angular.mock.$LogProvider = function() {
|
|||
if (angular.isString(timestamp)) {
|
||||
var tsStr = timestamp;
|
||||
|
||||
self.origDate = jsonStringToDate(timestamp)
|
||||
self.origDate = jsonStringToDate(timestamp);
|
||||
|
||||
timestamp = self.origDate.getTime();
|
||||
if (isNaN(timestamp))
|
||||
|
|
@ -1224,7 +1226,7 @@ function createHttpBackendMock($delegate, $browser) {
|
|||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function MockHttpExpectation(method, url, data, headers) {
|
||||
|
||||
|
|
@ -1544,7 +1546,6 @@ window.jasmine && (function(window) {
|
|||
*/
|
||||
window.module = angular.mock.module = function() {
|
||||
var moduleFns = Array.prototype.slice.call(arguments, 0);
|
||||
var stack = new Error('Module Declaration Location:').stack;
|
||||
return isSpecRunning() ? workFn() : workFn;
|
||||
/////////////////////
|
||||
function workFn() {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ angular.scenario.ObjectModel = function(runner) {
|
|||
self.emit('StepBegin', it, step);
|
||||
});
|
||||
|
||||
runner.on('StepEnd', function(spec, step) {
|
||||
runner.on('StepEnd', function(spec) {
|
||||
var it = self.getSpec(spec.id);
|
||||
var step = it.getLastStep();
|
||||
if (step.name !== step.name)
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ function asyncForEach(list, iterator, done) {
|
|||
* to a specific line length.
|
||||
*
|
||||
* @param {Object} error The exception to format, can be anything throwable
|
||||
* @param {Number} maxStackLines Optional. max lines of the stack trace to include
|
||||
* @param {Number=} [maxStackLines=5] max lines of the stack trace to include
|
||||
* default is 5.
|
||||
*/
|
||||
function formatException(error, maxStackLines) {
|
||||
|
|
@ -307,7 +307,7 @@ function browserTrigger(element, type, keys) {
|
|||
pressed('shift'), pressed('meta'), 0, element);
|
||||
|
||||
element.dispatchEvent(evnt);
|
||||
finalProcessDefault = !(appWindow.angular['ff-684208-preventDefault'] || !fakeProcessDefault)
|
||||
finalProcessDefault = !(appWindow.angular['ff-684208-preventDefault'] || !fakeProcessDefault);
|
||||
|
||||
delete appWindow.angular['ff-684208-preventDefault'];
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ angular.scenario.dsl('browser', function() {
|
|||
return api;
|
||||
};
|
||||
|
||||
return function(time) {
|
||||
return function() {
|
||||
return chain;
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ angular.scenario.output('html', function(context, runner, model) {
|
|||
'</div>'
|
||||
);
|
||||
|
||||
runner.on('InteractivePause', function(spec, step) {
|
||||
runner.on('InteractivePause', function(spec) {
|
||||
var ui = lastStepUiMap[spec.id];
|
||||
ui.find('.test-title').
|
||||
html('paused... <a href="javascript:resume()">resume</a> when ready.');
|
||||
|
|
|
|||
Loading…
Reference in a new issue