fix: throw for synthetic properties / listeners by default (#14880)

This allows to detect the case that the animation module is not loaded.
This commit is contained in:
Tobias Bosch
2017-03-06 17:15:08 -08:00
committed by Chuck Jazdzewski
parent ba4b6f58d9
commit 3651d8d673
7 changed files with 85 additions and 9 deletions

View File

@ -182,12 +182,16 @@ class DefaultDomRendererV2 implements RendererV2 {
}
}
setProperty(el: any, name: string, value: any): void { el[name] = value; }
setProperty(el: any, name: string, value: any): void {
checkNoSyntheticProp(name, 'property');
el[name] = value;
}
setValue(node: any, value: string): void { node.nodeValue = value; }
listen(target: 'window'|'document'|'body'|any, event: string, callback: (event: any) => boolean):
() => void {
checkNoSyntheticProp(event, 'listener');
if (typeof target === 'string') {
return <() => void>this.eventManager.addGlobalEventListener(
target, event, decoratePreventDefault(callback));
@ -197,6 +201,14 @@ class DefaultDomRendererV2 implements RendererV2 {
}
}
const AT_CHARCODE = '@'.charCodeAt(0);
function checkNoSyntheticProp(name: string, nameKind: string) {
if (name.charCodeAt(0) === AT_CHARCODE) {
throw new Error(
`Found the synthetic ${nameKind} ${name}. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.`);
}
}
class EmulatedEncapsulationDomRendererV2 extends DefaultDomRendererV2 {
private contentAttr: string;
private hostAttr: string;