diff --git a/packages/compiler/src/render3/view/t2_binder.ts b/packages/compiler/src/render3/view/t2_binder.ts index 53b363afcc172..f4abcb6a1c6ad 100644 --- a/packages/compiler/src/render3/view/t2_binder.ts +++ b/packages/compiler/src/render3/view/t2_binder.ts @@ -434,7 +434,10 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor { visitText(text: Text) {} visitContent(content: Content) {} visitTextAttribute(attribute: TextAttribute) {} - visitIcu(icu: Icu): void {} + visitIcu(icu: Icu): void { + Object.keys(icu.vars).forEach(key => icu.vars[key].visit(this)); + Object.keys(icu.placeholders).forEach(key => icu.placeholders[key].visit(this)); + } // The remaining visitors are concerned with processing AST expressions within template bindings diff --git a/packages/compiler/test/render3/view/binding_spec.ts b/packages/compiler/test/render3/view/binding_spec.ts index a1c51254544d2..6afb9c011ddae 100644 --- a/packages/compiler/test/render3/view/binding_spec.ts +++ b/packages/compiler/test/render3/view/binding_spec.ts @@ -194,4 +194,38 @@ describe('t2 binding', () => { expect(consumer).toEqual(el); }); }); + + describe('used pipes', () => { + it('should record pipes used in interpolations', () => { + const template = parseTemplate('{{value|date}}', '', {}); + const binder = new R3TargetBinder(makeSelectorMatcher()); + const res = binder.bind({template: template.nodes}); + expect(res.getUsedPipes()).toEqual(['date']); + }); + + it('should record pipes used in bound attributes', () => { + const template = parseTemplate('', '', {}); + const binder = new R3TargetBinder(makeSelectorMatcher()); + const res = binder.bind({template: template.nodes}); + expect(res.getUsedPipes()).toEqual(['number']); + }); + + it('should record pipes used in bound template attributes', () => { + const template = parseTemplate('', '', {}); + const binder = new R3TargetBinder(makeSelectorMatcher()); + const res = binder.bind({template: template.nodes}); + expect(res.getUsedPipes()).toEqual(['async']); + }); + + it('should record pipes used in ICUs', () => { + const template = parseTemplate( + `{count|number, plural, + =1 { {{value|date}} } + }`, + '', {}); + const binder = new R3TargetBinder(makeSelectorMatcher()); + const res = binder.bind({template: template.nodes}); + expect(res.getUsedPipes()).toEqual(['number', 'date']); + }); + }); });