refactor(core): introduce NgModule.schemas
This allows Angular to error on unknown properties, allowing applications that don’t use custom elements to get better error reporting. Part of #10043 BREAKING CHANGE: - By default, Angular will error during parsing on unknown properties, even if they are on elements with a `-` in their name (aka custom elements). If you application is using custom elements, fill the new parameter `@NgModule.schemas` with the value `[CUSTOM_ELEMENTS_SCHEMA]`. E.g. for bootstrap: ``` bootstrap(MyComponent, {schemas: [CUSTOM_ELEMENTS_SCHEMA]}); ```
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import * as common from '@angular/common';
|
||||
import {Component, Inject, OpaqueToken} from '@angular/core';
|
||||
import {CUSTOM_ELEMENTS_SCHEMA, Component, Inject, NgModule, OpaqueToken} from '@angular/core';
|
||||
|
||||
import {wrapInArray} from './funcs';
|
||||
|
||||
@ -37,3 +37,16 @@ export class CompWithProviders {
|
||||
})
|
||||
export class CompWithReferences {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'cmp-custom-els',
|
||||
template: `
|
||||
<some-custom-element [someUnknownProp]="true"></some-custom-element>
|
||||
`,
|
||||
})
|
||||
export class CompUsingCustomElements {
|
||||
}
|
||||
|
||||
@NgModule({schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [CompUsingCustomElements]})
|
||||
export class ModuleUsingCustomElements {
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import {BrowserModule} from '@angular/platform-browser';
|
||||
import {AnimateCmp} from './animate';
|
||||
import {BasicComp} from './basic';
|
||||
import {CompWithAnalyzeEntryComponentsProvider, CompWithEntryComponents} from './entry_components';
|
||||
import {CompWithProviders, CompWithReferences} from './features';
|
||||
import {CompWithProviders, CompWithReferences, ModuleUsingCustomElements} from './features';
|
||||
import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, someLibModuleWithProviders, SomePipeInRootModule, SomeService} from './module_fixtures';
|
||||
import {ProjectingComp} from './projection';
|
||||
import {CompWithChildQuery, CompWithDirectiveChild} from './queries';
|
||||
@ -25,7 +25,7 @@ import {CompWithChildQuery, CompWithDirectiveChild} from './queries';
|
||||
CompWithDirectiveChild, CompUsingRootModuleDirectiveAndPipe, CompWithProviders,
|
||||
CompWithReferences
|
||||
],
|
||||
imports: [BrowserModule, FormsModule, someLibModuleWithProviders()],
|
||||
imports: [BrowserModule, FormsModule, someLibModuleWithProviders(), ModuleUsingCustomElements],
|
||||
providers: [SomeService],
|
||||
entryComponents: [
|
||||
AnimateCmp, BasicComp, CompWithEntryComponents, CompWithAnalyzeEntryComponentsProvider,
|
||||
|
Reference in New Issue
Block a user