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

fix($parse): fix parse errors on older Android WebViews which choke with reserved keywords #11455

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
@@ -784,7 +784,7 @@ ASTCompiler.prototype = {
self.state.computing = fnKey;
var intoId = self.nextId();
self.recurse(watch, intoId);
self.return(intoId);
self['return'](intoId);
self.state.inputs.push(fnKey);
watch.watchId = key;
});
@@ -871,7 +871,7 @@ ASTCompiler.prototype = {
recursionFn = recursionFn || noop;
if (!skipWatchIdCheck && isDefined(ast.watchId)) {
intoId = intoId || this.nextId();
this.if('i',
this['if']('i',
this.lazyAssign(intoId, this.computedMember('i', ast.watchId)),
this.lazyRecurse(ast, intoId, nameId, recursionFn, create, true)
);
@@ -884,7 +884,7 @@ ASTCompiler.prototype = {
if (pos !== ast.body.length - 1) {
self.current().body.push(right, ';');
} else {
self.return(right);
self['return'](right);
}
});
break;
@@ -915,13 +915,13 @@ ASTCompiler.prototype = {
case AST.LogicalExpression:
intoId = intoId || this.nextId();
self.recurse(ast.left, intoId);
self.if(ast.operator === '&&' ? intoId : self.not(intoId), self.lazyRecurse(ast.right, intoId));
self['if'](ast.operator === '&&' ? intoId : self.not(intoId), self.lazyRecurse(ast.right, intoId));
recursionFn(intoId);
break;
case AST.ConditionalExpression:
intoId = intoId || this.nextId();
self.recurse(ast.test, intoId);
self.if(intoId, self.lazyRecurse(ast.alternate, intoId), self.lazyRecurse(ast.consequent, intoId));
self['if'](intoId, self.lazyRecurse(ast.alternate, intoId), self.lazyRecurse(ast.consequent, intoId));
recursionFn(intoId);
break;
case AST.Identifier:
@@ -932,11 +932,11 @@ ASTCompiler.prototype = {
nameId.name = ast.name;
}
ensureSafeMemberName(ast.name);
self.if(self.stage === 'inputs' || self.not(self.getHasOwnProperty('l', ast.name)),
self['if'](self.stage === 'inputs' || self.not(self.getHasOwnProperty('l', ast.name)),
function() {
self.if(self.stage === 'inputs' || 's', function() {
self['if'](self.stage === 'inputs' || 's', function() {
if (create && create !== 1) {
self.if(
self['if'](
self.not(self.nonComputedMember('s', ast.name)),
self.lazyAssign(self.nonComputedMember('s', ast.name), '{}'));
}
@@ -953,13 +953,13 @@ ASTCompiler.prototype = {
left = nameId && (nameId.context = this.nextId()) || this.nextId();
intoId = intoId || this.nextId();
self.recurse(ast.object, left, undefined, function() {
self.if(self.notNull(left), function() {
self['if'](self.notNull(left), function() {
if (ast.computed) {
right = self.nextId();
self.recurse(ast.property, right);
self.addEnsureSafeMemberName(right);
if (create && create !== 1) {
self.if(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), '{}'));
self['if'](self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), '{}'));
}
expression = self.ensureSafeObject(self.computedMember(left, right));
self.assign(intoId, expression);
@@ -970,7 +970,7 @@ ASTCompiler.prototype = {
} else {
ensureSafeMemberName(ast.property.name);
if (create && create !== 1) {
self.if(self.not(self.nonComputedMember(left, ast.property.name)), self.lazyAssign(self.nonComputedMember(left, ast.property.name), '{}'));
self['if'](self.not(self.nonComputedMember(left, ast.property.name)), self.lazyAssign(self.nonComputedMember(left, ast.property.name), '{}'));
}
expression = self.nonComputedMember(left, ast.property.name);
if (self.state.expensiveChecks || isPossiblyDangerousMemberName(ast.property.name)) {
@@ -1004,7 +1004,7 @@ ASTCompiler.prototype = {
left = {};
args = [];
self.recurse(ast.callee, right, left, function() {
self.if(self.notNull(right), function() {
self['if'](self.notNull(right), function() {
self.addEnsureSafeFunction(right);
forEach(ast.arguments, function(expr) {
self.recurse(expr, self.nextId(), undefined, function(argument) {
@@ -1033,7 +1033,7 @@ ASTCompiler.prototype = {
throw $parseMinErr('lval', 'Trying to assing a value to a non l-value');
}
this.recurse(ast.left, undefined, left, function() {
self.if(self.notNull(left.context), function() {
self['if'](self.notNull(left.context), function() {
self.recurse(ast.right, right);
self.addEnsureSafeObject(self.member(left.context, left.name, left.computed));
expression = self.member(left.context, left.name, left.computed) + ast.operator + right;