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

@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {SecurityContext} from '@angular/core';
import {SchemaMetadata, SecurityContext} from '@angular/core';
import {ElementSchemaRegistry} from '../index';
import {isPresent} from '../src/facade/lang';
@ -15,7 +16,7 @@ export class MockSchemaRegistry implements ElementSchemaRegistry {
public existingProperties: {[key: string]: boolean},
public attrPropMapping: {[key: string]: string}) {}
hasProperty(tagName: string, property: string): boolean {
hasProperty(tagName: string, property: string, schemas: SchemaMetadata[]): boolean {
var result = this.existingProperties[property];
return isPresent(result) ? result : true;
}