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]}); ```
33 lines
1016 B
TypeScript
33 lines
1016 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {SchemaMetadata, SecurityContext} from '@angular/core';
|
|
|
|
import {ElementSchemaRegistry} from '../index';
|
|
import {isPresent} from '../src/facade/lang';
|
|
|
|
export class MockSchemaRegistry implements ElementSchemaRegistry {
|
|
constructor(
|
|
public existingProperties: {[key: string]: boolean},
|
|
public attrPropMapping: {[key: string]: string}) {}
|
|
|
|
hasProperty(tagName: string, property: string, schemas: SchemaMetadata[]): boolean {
|
|
var result = this.existingProperties[property];
|
|
return isPresent(result) ? result : true;
|
|
}
|
|
|
|
securityContext(tagName: string, property: string): SecurityContext {
|
|
return SecurityContext.NONE;
|
|
}
|
|
|
|
getMappedPropName(attrName: string): string {
|
|
var result = this.attrPropMapping[attrName];
|
|
return isPresent(result) ? result : attrName;
|
|
}
|
|
}
|