From d5fcac4d7acc2a35889cda7b2aa2a49af3fac642 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Wed, 10 Dec 2014 19:21:15 -0800 Subject: [PATCH] feat(compiler): pass compilation unit to the parser --- .../change_detection_benchmark.js | 20 +++++----- modules/change_detection/src/parser/ast.js | 6 ++- modules/change_detection/src/parser/parser.js | 24 ++++++------ .../test/change_detector_spec.js | 4 +- .../test/parser/parser_spec.js | 37 +++++++++++++------ modules/core/src/compiler/compiler.js | 2 +- .../src/compiler/pipeline/default_steps.js | 13 +++++-- .../pipeline/property_binding_parser.js | 23 +++++++++--- .../pipeline/text_interpolation_parser.js | 6 ++- .../src/compiler/pipeline/view_splitter.js | 6 ++- .../pipeline/directive_parser_spec.js | 2 +- .../pipeline/element_binder_builder_spec.js | 6 +-- .../pipeline/property_binding_parser_spec.js | 2 +- .../text_interpolation_parser_spec.js | 2 +- .../compiler/pipeline/view_splitter_spec.js | 2 +- modules/core/test/compiler/view_spec.js | 24 ++++++------ modules/core/test/compiler/viewport_spec.js | 2 +- 17 files changed, 109 insertions(+), 72 deletions(-) diff --git a/modules/benchmarks/src/change_detection/change_detection_benchmark.js b/modules/benchmarks/src/change_detection/change_detection_benchmark.js index 6c35b0f0585..c49d1f15507 100644 --- a/modules/benchmarks/src/change_detection/change_detection_benchmark.js +++ b/modules/benchmarks/src/change_detection/change_detection_benchmark.js @@ -108,16 +108,16 @@ function setUpChangeDetection() { var parentRange = parentProto.instantiate(dispatcher, MapWrapper.create()); var astWithSource = [ - parser.parseBinding('field0'), - parser.parseBinding('field1'), - parser.parseBinding('field2'), - parser.parseBinding('field3'), - parser.parseBinding('field4'), - parser.parseBinding('field5'), - parser.parseBinding('field6'), - parser.parseBinding('field7'), - parser.parseBinding('field8'), - parser.parseBinding('field9') + parser.parseBinding('field0', null), + parser.parseBinding('field1', null), + parser.parseBinding('field2', null), + parser.parseBinding('field3', null), + parser.parseBinding('field4', null), + parser.parseBinding('field5', null), + parser.parseBinding('field6', null), + parser.parseBinding('field7', null), + parser.parseBinding('field8', null), + parser.parseBinding('field9', null) ]; function proto(i) { diff --git a/modules/change_detection/src/parser/ast.js b/modules/change_detection/src/parser/ast.js index cc5302c9eaf..11ff062ca0a 100644 --- a/modules/change_detection/src/parser/ast.js +++ b/modules/change_detection/src/parser/ast.js @@ -385,8 +385,10 @@ export class FunctionCall extends AST { export class ASTWithSource extends AST { ast:AST; source:string; - constructor(ast:AST, source:string) { + location:string; + constructor(ast:AST, source:string, location:string) { this.source = source; + this.location = location; this.ast = ast; } @@ -407,7 +409,7 @@ export class ASTWithSource extends AST { } toString():string { - return this.source; + return `${this.source} in ${this.location}`; } } diff --git a/modules/change_detection/src/parser/parser.js b/modules/change_detection/src/parser/parser.js index e60460e49dd..3197cf77463 100644 --- a/modules/change_detection/src/parser/parser.js +++ b/modules/change_detection/src/parser/parser.js @@ -36,32 +36,34 @@ export class Parser { this._reflector = isPresent(providedReflector) ? providedReflector : reflector; } - parseAction(input:string):ASTWithSource { + parseAction(input:string, location:any):ASTWithSource { var tokens = this._lexer.tokenize(input); - var ast = new _ParseAST(input, tokens, this._reflector, true).parseChain(); - return new ASTWithSource(ast, input); + var ast = new _ParseAST(input, location, tokens, this._reflector, true).parseChain(); + return new ASTWithSource(ast, input, location); } - parseBinding(input:string):ASTWithSource { + parseBinding(input:string, location:any):ASTWithSource { var tokens = this._lexer.tokenize(input); - var ast = new _ParseAST(input, tokens, this._reflector, false).parseChain(); - return new ASTWithSource(ast, input); + var ast = new _ParseAST(input, location, tokens, this._reflector, false).parseChain(); + return new ASTWithSource(ast, input, location); } - parseTemplateBindings(input:string):List { + parseTemplateBindings(input:string, location:any):List { var tokens = this._lexer.tokenize(input); - return new _ParseAST(input, tokens, this._reflector, false).parseTemplateBindings(); + return new _ParseAST(input, location, tokens, this._reflector, false).parseTemplateBindings(); } } class _ParseAST { input:string; + location:any; tokens:List; reflector:Reflector; parseAction:boolean; index:int; - constructor(input:string, tokens:List, reflector:Reflector, parseAction:boolean) { + constructor(input:string, location:any, tokens:List, reflector:Reflector, parseAction:boolean) { this.input = input; + this.location = location; this.tokens = tokens; this.index = 0; this.reflector = reflector; @@ -451,7 +453,7 @@ class _ParseAST { var start = this.inputIndex; var ast = this.parseExpression(); var source = this.input.substring(start, this.inputIndex); - expression = new ASTWithSource(ast, source); + expression = new ASTWithSource(ast, source, this.location); } } ListWrapper.push(bindings, new TemplateBinding(key, name, expression)); @@ -469,6 +471,6 @@ class _ParseAST { ? `at column ${this.tokens[index].index + 1} in` : `at the end of the expression`; - throw new BaseException(`Parser Error: ${message} ${location} [${this.input}]`); + throw new BaseException(`Parser Error: ${message} ${location} [${this.input}] in ${this.location}`); } } diff --git a/modules/change_detection/test/change_detector_spec.js b/modules/change_detection/test/change_detector_spec.js index b22b50434da..d063e1581a1 100644 --- a/modules/change_detection/test/change_detector_spec.js +++ b/modules/change_detection/test/change_detector_spec.js @@ -20,7 +20,7 @@ import {Record} from 'change_detection/record'; export function main() { function ast(exp:string) { var parser = new Parser(new Lexer()); - return parser.parseBinding(exp); + return parser.parseBinding(exp, 'location'); } function createChangeDetector(memo:string, exp:string, context = null, formatters = null, @@ -451,7 +451,7 @@ export function main() { expect(() => { var cd = new ChangeDetector(rr, true); cd.detectChanges(); - }).toThrowError(new RegExp("Expression 'a' has changed after it was checked")); + }).toThrowError(new RegExp("Expression 'a in location' has changed after it was checked")); }); }); }); diff --git a/modules/change_detection/test/parser/parser_spec.js b/modules/change_detection/test/parser/parser_spec.js index 9160157e9dd..d0f907249e7 100644 --- a/modules/change_detection/test/parser/parser_spec.js +++ b/modules/change_detection/test/parser/parser_spec.js @@ -35,16 +35,16 @@ export function main() { return new Parser(new Lexer(), reflector); } - function parseAction(text) { - return createParser().parseAction(text).ast; + function parseAction(text, location = null) { + return createParser().parseAction(text, location); } - function parseBinding(text) { - return createParser().parseBinding(text).ast; + function parseBinding(text, location = null) { + return createParser().parseBinding(text, location); } - function parseTemplateBindings(text) { - return createParser().parseTemplateBindings(text); + function parseTemplateBindings(text, location = null) { + return createParser().parseTemplateBindings(text, location); } function expectEval(text, passedInContext = null) { @@ -340,7 +340,7 @@ export function main() { it('should pass exceptions', () => { expect(() => { - createParser().parseAction('a()').ast.eval(td(() => {throw new BaseException("boo to you")})); + parseAction('a()').eval(td(() => {throw new BaseException("boo to you")})); }).toThrowError('boo to you'); }); @@ -352,20 +352,24 @@ export function main() { }); it('should store the source in the result', () => { - expect(createParser().parseAction('someExpr').source).toBe('someExpr'); + expect(parseAction('someExpr').source).toBe('someExpr'); + }); + + it('should store the passed-in location', () => { + expect(parseAction('someExpr', 'location').location).toBe('location'); }); }); describe("parseBinding", () => { describe("formatters", () => { it("should parse formatters", () => { - var exp = parseBinding("'Foo'|uppercase"); + var exp = parseBinding("'Foo'|uppercase").ast; expect(exp).toBeAnInstanceOf(Formatter); expect(exp.name).toEqual("uppercase"); }); it("should parse formatters with args", () => { - var exp = parseBinding("1|increment:2"); + var exp = parseBinding("1|increment:2").ast; expect(exp).toBeAnInstanceOf(Formatter); expect(exp.name).toEqual("increment"); expect(exp.args[0]).toBeAnInstanceOf(LiteralPrimitive); @@ -380,7 +384,11 @@ export function main() { }); it('should store the source in the result', () => { - expect(createParser().parseBinding('someExpr').source).toBe('someExpr'); + expect(parseBinding('someExpr').source).toBe('someExpr'); + }); + + it('should store the passed-in location', () => { + expect(parseBinding('someExpr', 'location').location).toBe('location'); }); it('should throw on chain expressions', () => { @@ -409,7 +417,7 @@ export function main() { function exprAsts(templateBindings) { return ListWrapper.map(templateBindings, - (binding) => isPresent(binding.expression) ? binding.expression.ast : null ); + (binding) => isPresent(binding.expression) ? binding.expression : null ); } it('should parse an empty string', () => { @@ -482,6 +490,11 @@ export function main() { expect(bindings[0].expression.source).toEqual('1'); expect(bindings[1].expression.source).toEqual('2'); }); + + it('should store the passed-in location', () => { + var bindings = parseTemplateBindings("a 1,b 2", 'location'); + expect(bindings[0].expression.location).toEqual('location'); + }); }); }); } diff --git a/modules/core/src/compiler/compiler.js b/modules/core/src/compiler/compiler.js index b31e2f7b5cb..9ab2f6545dc 100644 --- a/modules/core/src/compiler/compiler.js +++ b/modules/core/src/compiler/compiler.js @@ -62,7 +62,7 @@ export class Compiler { for (var i=0; i { diff --git a/modules/core/src/compiler/pipeline/default_steps.js b/modules/core/src/compiler/pipeline/default_steps.js index 6a7ce16c8f2..51952be99ff 100644 --- a/modules/core/src/compiler/pipeline/default_steps.js +++ b/modules/core/src/compiler/pipeline/default_steps.js @@ -9,17 +9,22 @@ import {ElementBindingMarker} from './element_binding_marker'; import {ProtoViewBuilder} from './proto_view_builder'; import {ProtoElementInjectorBuilder} from './proto_element_injector_builder'; import {ElementBinderBuilder} from './element_binder_builder'; +import {AnnotatedType} from 'core/compiler/annotated_type'; +import {stringify} from 'facade/lang'; /** * Default steps used for compiling a template. * Takes in an HTMLElement and produces the ProtoViews, * ProtoElementInjectors and ElementBinders in the end. */ -export function createDefaultSteps(parser:Parser, directives: List) { +export function createDefaultSteps(parser:Parser, compiledComponent: AnnotatedType, + directives: List) { + var compilationUnit = stringify(compiledComponent.type); + return [ - new ViewSplitter(parser), - new TextInterpolationParser(parser), - new PropertyBindingParser(parser), + new ViewSplitter(parser, compilationUnit), + new TextInterpolationParser(parser, compilationUnit), + new PropertyBindingParser(parser, compilationUnit), new DirectiveParser(directives), new ElementBindingMarker(), new ProtoViewBuilder(), diff --git a/modules/core/src/compiler/pipeline/property_binding_parser.js b/modules/core/src/compiler/pipeline/property_binding_parser.js index 8b54b358e5e..e593f3386e4 100644 --- a/modules/core/src/compiler/pipeline/property_binding_parser.js +++ b/modules/core/src/compiler/pipeline/property_binding_parser.js @@ -3,6 +3,7 @@ import {MapWrapper} from 'facade/collection'; import {TemplateElement} from 'facade/dom'; import {Parser} from 'change_detection/parser/parser'; +import {AST} from 'change_detection/parser/ast'; import {ExpressionWithSource} from 'change_detection/parser/ast'; import {CompileStep} from './compile_step'; @@ -24,8 +25,10 @@ var BIND_NAME_REGEXP = RegExpWrapper.create('^(?:(?:(bind)|(let)|(on))-(.+))|\\[ */ export class PropertyBindingParser extends CompileStep { _parser:Parser; - constructor(parser:Parser) { + _compilationUnit:any; + constructor(parser:Parser, compilationUnit:any) { this._parser = parser; + this._compilationUnit = compilationUnit; } process(parent:CompileElement, current:CompileElement, control:CompileControl) { @@ -35,7 +38,7 @@ export class PropertyBindingParser extends CompileStep { if (isPresent(bindParts)) { if (isPresent(bindParts[1])) { // match: bind-prop - current.addPropertyBinding(bindParts[4], this._parser.parseBinding(attrValue)); + current.addPropertyBinding(bindParts[4], this._parseBinding(attrValue)); } else if (isPresent(bindParts[2])) { // match: let-prop // Note: We assume that the ViewSplitter already did its work, i.e. template directive should @@ -46,20 +49,28 @@ export class PropertyBindingParser extends CompileStep { current.addVariableBinding(bindParts[4], attrValue); } else if (isPresent(bindParts[3])) { // match: on-prop - current.addEventBinding(bindParts[4], this._parser.parseAction(attrValue)); + current.addEventBinding(bindParts[4], this._parseAction(attrValue)); } else if (isPresent(bindParts[5])) { // match: [prop] - current.addPropertyBinding(bindParts[5], this._parser.parseBinding(attrValue)); + current.addPropertyBinding(bindParts[5], this._parseBinding(attrValue)); } else if (isPresent(bindParts[6])) { // match: (prop) - current.addEventBinding(bindParts[6], this._parser.parseBinding(attrValue)); + current.addEventBinding(bindParts[6], this._parseBinding(attrValue)); } } else { var expression = interpolationToExpression(attrValue); if (isPresent(expression)) { - current.addPropertyBinding(attrName, this._parser.parseBinding(expression)); + current.addPropertyBinding(attrName, this._parseBinding(expression)); } } }); } + + _parseBinding(input:string):AST { + return this._parser.parseBinding(input, this._compilationUnit); + } + + _parseAction(input:string):AST { + return this._parser.parseAction(input, this._compilationUnit); + } } diff --git a/modules/core/src/compiler/pipeline/text_interpolation_parser.js b/modules/core/src/compiler/pipeline/text_interpolation_parser.js index 60d3d94c85b..58c60ff8a5c 100644 --- a/modules/core/src/compiler/pipeline/text_interpolation_parser.js +++ b/modules/core/src/compiler/pipeline/text_interpolation_parser.js @@ -47,8 +47,10 @@ export function interpolationToExpression(value:string):string { */ export class TextInterpolationParser extends CompileStep { _parser:Parser; - constructor(parser:Parser) { + _compilationUnit:any; + constructor(parser:Parser, compilationUnit:any) { this._parser = parser; + this._compilationUnit = compilationUnit; } process(parent:CompileElement, current:CompileElement, control:CompileControl) { @@ -66,7 +68,7 @@ export class TextInterpolationParser extends CompileStep { var expression = interpolationToExpression(node.nodeValue); if (isPresent(expression)) { DOM.setText(node, ' '); - pipelineElement.addTextNodeBinding(nodeIndex, this._parser.parseBinding(expression)); + pipelineElement.addTextNodeBinding(nodeIndex, this._parser.parseBinding(expression, this._compilationUnit)); } } } diff --git a/modules/core/src/compiler/pipeline/view_splitter.js b/modules/core/src/compiler/pipeline/view_splitter.js index ba3fa1b3602..627c396fe86 100644 --- a/modules/core/src/compiler/pipeline/view_splitter.js +++ b/modules/core/src/compiler/pipeline/view_splitter.js @@ -31,8 +31,10 @@ import {CompileControl} from './compile_control'; */ export class ViewSplitter extends CompileStep { _parser:Parser; - constructor(parser:Parser) { + _compilationUnit:any; + constructor(parser:Parser, compilationUnit:any) { this._parser = parser; + this._compilationUnit = compilationUnit; } process(parent:CompileElement, current:CompileElement, control:CompileControl) { @@ -74,7 +76,7 @@ export class ViewSplitter extends CompileStep { } _parseTemplateBindings(templateBindings:string, compileElement:CompileElement) { - var bindings = this._parser.parseTemplateBindings(templateBindings); + var bindings = this._parser.parseTemplateBindings(templateBindings, this._compilationUnit); for (var i=0; i { if (isPresent(propertyBindings)) { StringMapWrapper.forEach(propertyBindings, (v, k) => { - current.addPropertyBinding(k, parser.parseBinding(v)); + current.addPropertyBinding(k, parser.parseBinding(v, null)); }); } if (isPresent(variableBindings)) { diff --git a/modules/core/test/compiler/pipeline/element_binder_builder_spec.js b/modules/core/test/compiler/pipeline/element_binder_builder_spec.js index ef2dae60b1a..8d7bb22a9e6 100644 --- a/modules/core/test/compiler/pipeline/element_binder_builder_spec.js +++ b/modules/core/test/compiler/pipeline/element_binder_builder_spec.js @@ -35,21 +35,21 @@ export function main() { var hasBinding = false; if (isPresent(current.element.getAttribute('text-binding'))) { MapWrapper.forEach(textNodeBindings, (v,k) => { - current.addTextNodeBinding(k, parser.parseBinding(v)); + current.addTextNodeBinding(k, parser.parseBinding(v, null)); }); hasBinding = true; } if (isPresent(current.element.getAttribute('prop-binding'))) { if (isPresent(propertyBindings)) { MapWrapper.forEach(propertyBindings, (v,k) => { - current.addPropertyBinding(k, parser.parseBinding(v)); + current.addPropertyBinding(k, parser.parseBinding(v, null)); }); } hasBinding = true; } if (isPresent(current.element.getAttribute('event-binding'))) { MapWrapper.forEach(eventBindings, (v,k) => { - current.addEventBinding(k, parser.parseAction(v)); + current.addEventBinding(k, parser.parseAction(v, null)); }); hasBinding = true; } diff --git a/modules/core/test/compiler/pipeline/property_binding_parser_spec.js b/modules/core/test/compiler/pipeline/property_binding_parser_spec.js index 9d0315f7771..ea94fc21f30 100644 --- a/modules/core/test/compiler/pipeline/property_binding_parser_spec.js +++ b/modules/core/test/compiler/pipeline/property_binding_parser_spec.js @@ -10,7 +10,7 @@ import {Lexer} from 'change_detection/parser/lexer'; export function main() { describe('PropertyBindingParser', () => { function createPipeline() { - return new CompilePipeline([new PropertyBindingParser(new Parser(new Lexer()))]); + return new CompilePipeline([new PropertyBindingParser(new Parser(new Lexer()), null)]); } it('should detect [] syntax', () => { diff --git a/modules/core/test/compiler/pipeline/text_interpolation_parser_spec.js b/modules/core/test/compiler/pipeline/text_interpolation_parser_spec.js index 01df27bf40f..79bf75f46e3 100644 --- a/modules/core/test/compiler/pipeline/text_interpolation_parser_spec.js +++ b/modules/core/test/compiler/pipeline/text_interpolation_parser_spec.js @@ -10,7 +10,7 @@ import {Lexer} from 'change_detection/parser/lexer'; export function main() { describe('TextInterpolationParser', () => { function createPipeline() { - return new CompilePipeline([new TextInterpolationParser(new Parser(new Lexer()))]); + return new CompilePipeline([new TextInterpolationParser(new Parser(new Lexer()), null)]); } it('should find text interpolation in normal elements', () => { diff --git a/modules/core/test/compiler/pipeline/view_splitter_spec.js b/modules/core/test/compiler/pipeline/view_splitter_spec.js index a8818f1853c..9432e9ac80a 100644 --- a/modules/core/test/compiler/pipeline/view_splitter_spec.js +++ b/modules/core/test/compiler/pipeline/view_splitter_spec.js @@ -13,7 +13,7 @@ export function main() { describe('ViewSplitter', () => { function createPipeline() { - return new CompilePipeline([new ViewSplitter(new Parser(new Lexer()))]); + return new CompilePipeline([new ViewSplitter(new Parser(new Lexer()), null)]); } it('should mark root elements as viewRoot', () => { diff --git a/modules/core/test/compiler/view_spec.js b/modules/core/test/compiler/view_spec.js index 16431df4839..aaf297c3b99 100644 --- a/modules/core/test/compiler/view_spec.js +++ b/modules/core/test/compiler/view_spec.js @@ -105,7 +105,7 @@ export function main() { it('should collect property bindings on the root element if it has the ng-binding class', () => { var pv = new ProtoView(templateAwareCreateElement('
'), new ProtoRecordRange()); pv.bindElement(null); - pv.bindElementProperty(parser.parseBinding('a').ast, 'prop', reflector.setter('prop')); + pv.bindElementProperty(parser.parseBinding('a', null), 'prop', reflector.setter('prop')); var view = pv.instantiate(null); view.hydrate(null, null, null); @@ -117,7 +117,7 @@ export function main() { var pv = new ProtoView(templateAwareCreateElement('
'), new ProtoRecordRange()); pv.bindElement(null); - pv.bindElementProperty(parser.parseBinding('b').ast, 'a', reflector.setter('a')); + pv.bindElementProperty(parser.parseBinding('b', null), 'a', reflector.setter('a')); var view = pv.instantiate(null); view.hydrate(null, null, null); @@ -132,8 +132,8 @@ export function main() { it('should collect text nodes under the root element', () => { var pv = new ProtoView(templateAwareCreateElement('
{{}}{{}}
'), new ProtoRecordRange()); pv.bindElement(null); - pv.bindTextNode(0, parser.parseBinding('a')); - pv.bindTextNode(2, parser.parseBinding('b')); + pv.bindTextNode(0, parser.parseBinding('a', null)); + pv.bindTextNode(2, parser.parseBinding('b', null)); var view = pv.instantiate(null); view.hydrate(null, null, null); @@ -146,7 +146,7 @@ export function main() { var pv = new ProtoView(templateAwareCreateElement('
{{}}
'), new ProtoRecordRange()); pv.bindElement(null); - pv.bindTextNode(0, parser.parseBinding('b')); + pv.bindTextNode(0, parser.parseBinding('b', null)); var view = pv.instantiate(null); view.hydrate(null, null, null); @@ -358,7 +358,7 @@ export function main() { var pv = new ProtoView(createElement('
{{}}
'), new ProtoRecordRange()); pv.bindElement(null); - pv.bindTextNode(0, parser.parseBinding('foo')); + pv.bindTextNode(0, parser.parseBinding('foo', null)); createViewAndChangeDetector(pv); ctx.foo = 'buz'; @@ -370,7 +370,7 @@ export function main() { var pv = new ProtoView(createElement('
'), new ProtoRecordRange()); pv.bindElement(null); - pv.bindElementProperty(parser.parseBinding('foo').ast, 'id', reflector.setter('id')); + pv.bindElementProperty(parser.parseBinding('foo', null), 'id', reflector.setter('id')); createViewAndChangeDetector(pv); ctx.foo = 'buz'; @@ -382,7 +382,7 @@ export function main() { var pv = new ProtoView(createElement('
'), new ProtoRecordRange()); pv.bindElement(new ProtoElementInjector(null, 0, [SomeDirective])); - pv.bindDirectiveProperty(0, parser.parseBinding('foo'), 'prop', reflector.setter('prop'), false); + pv.bindDirectiveProperty(0, parser.parseBinding('foo', null), 'prop', reflector.setter('prop'), false); createViewAndChangeDetector(pv); ctx.foo = 'buz'; @@ -395,8 +395,8 @@ export function main() { new ProtoRecordRange()); pv.bindElement(new ProtoElementInjector(null, 0, [DirectiveImplementingOnChange])); - pv.bindDirectiveProperty( 0, parser.parseBinding('a'), 'a', reflector.setter('a'), false); - pv.bindDirectiveProperty( 0, parser.parseBinding('b'), 'b', reflector.setter('b'), false); + pv.bindDirectiveProperty( 0, parser.parseBinding('a', null), 'a', reflector.setter('a'), false); + pv.bindDirectiveProperty( 0, parser.parseBinding('b', null), 'b', reflector.setter('b'), false); createViewAndChangeDetector(pv); ctx.a = 100; @@ -412,8 +412,8 @@ export function main() { new ProtoRecordRange()); pv.bindElement(new ProtoElementInjector(null, 0, [DirectiveImplementingOnChange])); - pv.bindDirectiveProperty( 0, parser.parseBinding('a').ast, 'a', reflector.setter('a'), false); - pv.bindDirectiveProperty( 0, parser.parseBinding('b').ast, 'b', reflector.setter('b'), false); + pv.bindDirectiveProperty( 0, parser.parseBinding('a', null), 'a', reflector.setter('a'), false); + pv.bindDirectiveProperty( 0, parser.parseBinding('b', null), 'b', reflector.setter('b'), false); createViewAndChangeDetector(pv); ctx.a = 0; diff --git a/modules/core/test/compiler/viewport_spec.js b/modules/core/test/compiler/viewport_spec.js index 29763ba1f4b..d2662df22b9 100644 --- a/modules/core/test/compiler/viewport_spec.js +++ b/modules/core/test/compiler/viewport_spec.js @@ -125,7 +125,7 @@ export function main() { var pv = new ProtoView(createElement('
{{}}
'), new ProtoRecordRange()); pv.bindElement(new ProtoElementInjector(null, 1, [SomeDirective])); - pv.bindTextNode(0, parser.parseBinding('foo').ast); + pv.bindTextNode(0, parser.parseBinding('foo', null)); fancyView = pv.instantiate(null); });