diff --git a/packages/core/src/render3/instructions/container.ts b/packages/core/src/render3/instructions/container.ts index 7c3797f0b0..67b563b61c 100644 --- a/packages/core/src/render3/instructions/container.ts +++ b/packages/core/src/render3/instructions/container.ts @@ -76,7 +76,8 @@ export function ɵɵtemplate( resolveDirectives(tView, lView, tContainerNode, localRefs || null); const embeddedTView = tContainerNode.tViews = createTView( - -1, templateFn, consts, vars, tView.directiveRegistry, tView.pipeRegistry, null, null); + -1, templateFn, consts, vars, tView.directiveRegistry, tView.pipeRegistry, null, + tView.schemas); if (tView.queries !== null) { tView.queries.template(tView, tContainerNode); embeddedTView.queries = tView.queries.embeddedTView(tContainerNode); diff --git a/packages/core/test/acceptance/ng_module_spec.ts b/packages/core/test/acceptance/ng_module_spec.ts index 8691e9ecab..b2e0ddb093 100644 --- a/packages/core/test/acceptance/ng_module_spec.ts +++ b/packages/core/test/acceptance/ng_module_spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {Component, NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {Component, NO_ERRORS_SCHEMA, NgModule} from '@angular/core'; import {TestBed} from '@angular/core/testing'; describe('NgModule', () => { @@ -74,4 +75,63 @@ describe('NgModule', () => { }); }); + describe('schemas', () => { + it('should throw on unknown props if NO_ERRORS_SCHEMA is absent', () => { + @Component({ + selector: 'my-comp', + template: ` + +
+
+ `, + }) + class MyComp { + condition = true; + } + + @NgModule({ + imports: [CommonModule], + declarations: [MyComp], + }) + class MyModule { + } + + TestBed.configureTestingModule({imports: [MyModule]}); + + expect(() => { + const fixture = TestBed.createComponent(MyComp); + fixture.detectChanges(); + }).toThrowError(/Can't bind to 'unknown-prop' since it isn't a known property of 'div'/); + }); + + it('should not throw on unknown props if NO_ERRORS_SCHEMA is present', () => { + @Component({ + selector: 'my-comp', + template: ` + +
+
+ `, + }) + class MyComp { + condition = true; + } + + @NgModule({ + imports: [CommonModule], + schemas: [NO_ERRORS_SCHEMA], + declarations: [MyComp], + }) + class MyModule { + } + + TestBed.configureTestingModule({imports: [MyModule]}); + + expect(() => { + const fixture = TestBed.createComponent(MyComp); + fixture.detectChanges(); + }).not.toThrow(); + }); + }); + });