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:
Tobias Bosch
2016-07-25 03:02:57 -07:00
parent f02da4e91a
commit 00b726f695
21 changed files with 249 additions and 101 deletions

View File

@ -12,6 +12,7 @@
* allows tests to be asynchronous by either returning a promise or using a 'done' parameter.
*/
import {SchemaMetadata} from '../index';
import {TestBed, getTestBed} from './test_bed';
declare var global: any;
@ -49,9 +50,13 @@ export function addProviders(providers: Array<any>): void {
*
* @stable
*/
export function configureModule(
moduleDef: {providers?: any[], declarations?: any[], imports?: any[], entryComponents?: any[]}):
void {
export function configureModule(moduleDef: {
providers?: any[],
declarations?: any[],
imports?: any[],
entryComponents?: any[],
schemas?: Array<SchemaMetadata|any[]>
}): void {
if (!moduleDef) return;
try {
testBed.configureModule(moduleDef);