mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-07 22:37:28 +08:00
refactor($parse): remove unused parameters and methods
After removing the json and unwrapPromise mode, some parameters and methods were no longer used.
This commit is contained in:
@@ -122,7 +122,6 @@ Lexer.prototype = {
|
||||
this.text = text;
|
||||
this.index = 0;
|
||||
this.ch = undefined;
|
||||
this.lastCh = ':'; // can start regexp
|
||||
this.tokens = [];
|
||||
|
||||
while (this.index < this.text.length) {
|
||||
@@ -141,7 +140,6 @@ Lexer.prototype = {
|
||||
this.index++;
|
||||
} else if (this.isWhitespace(this.ch)) {
|
||||
this.index++;
|
||||
continue;
|
||||
} else {
|
||||
var ch2 = this.ch + this.peek();
|
||||
var ch3 = ch2 + this.peek(2);
|
||||
@@ -165,7 +163,6 @@ Lexer.prototype = {
|
||||
this.throwError('Unexpected next character ', this.index, this.index + 1);
|
||||
}
|
||||
}
|
||||
this.lastCh = this.ch;
|
||||
}
|
||||
return this.tokens;
|
||||
},
|
||||
@@ -174,10 +171,6 @@ Lexer.prototype = {
|
||||
return chars.indexOf(this.ch) !== -1;
|
||||
},
|
||||
|
||||
was: function(chars) {
|
||||
return chars.indexOf(this.lastCh) !== -1;
|
||||
},
|
||||
|
||||
peek: function(i) {
|
||||
var num = i || 1;
|
||||
return (this.index + num < this.text.length) ? this.text.charAt(this.index + num) : false;
|
||||
@@ -300,7 +293,7 @@ Lexer.prototype = {
|
||||
return (getter(self, locals));
|
||||
}, {
|
||||
assign: function(self, value) {
|
||||
return setter(self, ident, value, parser.text, parser.options);
|
||||
return setter(self, ident, value, parser.text);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -672,7 +665,7 @@ Parser.prototype = {
|
||||
return getter(self || object(scope, locals));
|
||||
}, {
|
||||
assign: function(scope, value, locals) {
|
||||
return setter(object(scope, locals), field, value, parser.text, parser.options);
|
||||
return setter(object(scope, locals), field, value, parser.text);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -686,7 +679,7 @@ Parser.prototype = {
|
||||
return extend(function(self, locals) {
|
||||
var o = obj(self, locals),
|
||||
i = indexFn(self, locals),
|
||||
v, p;
|
||||
v;
|
||||
|
||||
if (!o) return undefined;
|
||||
v = ensureSafeObject(o[i], parser.text);
|
||||
@@ -804,9 +797,7 @@ Parser.prototype = {
|
||||
// Parser helper functions
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
function setter(obj, path, setValue, fullExp, options) {
|
||||
//needed?
|
||||
options = options || {};
|
||||
function setter(obj, path, setValue, fullExp) {
|
||||
|
||||
var element = path.split('.'), key;
|
||||
for (var i = 0; element.length > 1; i++) {
|
||||
@@ -830,7 +821,7 @@ var getterFnCache = {};
|
||||
* - http://jsperf.com/angularjs-parse-getter/4
|
||||
* - http://jsperf.com/path-evaluation-simplified/7
|
||||
*/
|
||||
function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) {
|
||||
function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp) {
|
||||
ensureSafeMemberName(key0, fullExp);
|
||||
ensureSafeMemberName(key1, fullExp);
|
||||
ensureSafeMemberName(key2, fullExp);
|
||||
@@ -903,14 +894,13 @@ function getterFn(path, options, fullExp) {
|
||||
fn = simpleGetterFn2(pathKeys[0], pathKeys[1], fullExp);
|
||||
} else if (options.csp) {
|
||||
if (pathKeysLength < 6) {
|
||||
fn = cspSafeGetterFn(pathKeys[0], pathKeys[1], pathKeys[2], pathKeys[3], pathKeys[4], fullExp,
|
||||
options);
|
||||
fn = cspSafeGetterFn(pathKeys[0], pathKeys[1], pathKeys[2], pathKeys[3], pathKeys[4], fullExp);
|
||||
} else {
|
||||
fn = function(scope, locals) {
|
||||
var i = 0, val;
|
||||
do {
|
||||
val = cspSafeGetterFn(pathKeys[i++], pathKeys[i++], pathKeys[i++], pathKeys[i++],
|
||||
pathKeys[i++], fullExp, options)(scope, locals);
|
||||
pathKeys[i++], fullExp)(scope, locals);
|
||||
|
||||
locals = undefined; // clear after first iteration
|
||||
scope = val;
|
||||
@@ -1006,7 +996,7 @@ function $ParseProvider() {
|
||||
};
|
||||
|
||||
|
||||
this.$get = ['$filter', '$sniffer', '$log', function($filter, $sniffer, $log) {
|
||||
this.$get = ['$filter', '$sniffer', function($filter, $sniffer) {
|
||||
$parseOptions.csp = $sniffer.csp;
|
||||
|
||||
return function(exp) {
|
||||
|
||||
Reference in New Issue
Block a user