Skip to content

Commit 8ad10fd

Browse files
JeanMecheNothingEverHappens
authored andcommitted
fix(compiler): fix detection of directive deps in JIT (#62666)
This fix also matches the implementation to the jsdoc for `hasDirectiveDependencies` "Whether any of the component's dependencies are directives" fixes #62573 PR Close #62666
1 parent c262557 commit 8ad10fd

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

packages/compiler/src/jit_compiler_facade.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ function convertDeclareComponentFacadeToMetadata(
657657
decl.pipes && declarations.push(...convertPipeMapToMetadata(decl.pipes));
658658
}
659659

660-
const hasDirectiveDependencies = declarations.every(
660+
const hasDirectiveDependencies = declarations.some(
661661
({kind}) =>
662662
kind === R3TemplateDependencyKind.Directive || kind === R3TemplateDependencyKind.NgModule,
663663
);

packages/core/test/render3/jit/declare_component_spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,35 @@ describe('component declaration jit compilation', () => {
387387
});
388388
});
389389

390+
it('should bind directive inputs as regular property (not DOM property) in the presence of pipes', () => {
391+
// https://github.com/angular/angular/issues/62573
392+
const def = ɵɵngDeclareComponent({
393+
version: '18.0.0',
394+
type: TestClass,
395+
isStandalone: true,
396+
dependencies: [
397+
{
398+
kind: 'directive',
399+
type: TestDir,
400+
selector: '[dir]',
401+
inputs: ['dir'],
402+
},
403+
{
404+
kind: 'pipe',
405+
type: TestPipe,
406+
name: 'test',
407+
},
408+
],
409+
template: `<div [dir]="'test' | test"></div>`,
410+
}) as ComponentDef<TestClass>;
411+
412+
expectComponentDef(def, {
413+
template: functionContaining([/property[^(]*\('dir',/]),
414+
directives: [TestDir],
415+
pipes: [TestPipe],
416+
});
417+
});
418+
390419
it('should compile used components', () => {
391420
const def = ɵɵngDeclareComponent({
392421
version: '18.0.0',

0 commit comments

Comments
 (0)