fix(compiler): support more than 9 interpolations (#12710)

Fixes #10253
This commit is contained in:
Pawel Kozlowski
2016-11-07 21:23:03 +01:00
committed by vikerman
parent d8f23f4b7f
commit 22c021c57f
8 changed files with 45 additions and 11 deletions

View File

@ -275,7 +275,12 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
args.push(this.visit(ast.expressions[i], _Mode.Expression));
}
args.push(o.literal(ast.strings[ast.strings.length - 1]));
return o.importExpr(resolveIdentifier(Identifiers.interpolate)).callFn(args);
return ast.expressions.length <= 9 ?
o.importExpr(resolveIdentifier(Identifiers.inlineInterpolate)).callFn(args) :
o.importExpr(resolveIdentifier(Identifiers.interpolate)).callFn([
args[0], o.literalArr(args.slice(1))
]);
}
visitKeyedRead(ast: cdAst.KeyedRead, mode: _Mode): any {

View File

@ -174,6 +174,11 @@ export class Identifiers {
};
static devModeEqual:
IdentifierSpec = {name: 'devModeEqual', moduleUrl: CD_MODULE_URL, runtime: devModeEqual};
static inlineInterpolate: IdentifierSpec = {
name: 'inlineInterpolate',
moduleUrl: VIEW_UTILS_MODULE_URL,
runtime: view_utils.inlineInterpolate
};
static interpolate: IdentifierSpec = {
name: 'interpolate',
moduleUrl: VIEW_UTILS_MODULE_URL,

View File

@ -104,11 +104,6 @@ export class BindingParser {
const ast = this._exprParser.parseInterpolation(value, sourceInfo, this._interpolationConfig);
if (ast) this._reportExpressionParserErrors(ast.errors, sourceSpan);
this._checkPipes(ast, sourceSpan);
if (ast &&
(<Interpolation>ast.ast).expressions.length > view_utils.MAX_INTERPOLATION_VALUES) {
throw new Error(
`Only support at most ${view_utils.MAX_INTERPOLATION_VALUES} interpolation values!`);
}
return ast;
} catch (e) {
this._reportError(`${e}`, sourceSpan);