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

@ -8,3 +8,4 @@
export {INTERNAL_SERVER_PLATFORM_PROVIDERS as ɵINTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_RENDER_PROVIDERS as ɵSERVER_RENDER_PROVIDERS} from './server';
export {ServerRendererFactoryV2 as ɵServerRendererFactoryV2} from './server_renderer';

View File

@ -146,6 +146,7 @@ class DefaultServerRendererV2 implements RendererV2 {
}
setProperty(el: any, name: string, value: any): void {
checkNoSyntheticProp(name, 'property');
getDOM().setProperty(el, name, value);
// Mirror property values for known HTML element properties in the attributes.
const tagName = (el.tagName as string).toLowerCase();
@ -164,6 +165,7 @@ class DefaultServerRendererV2 implements RendererV2 {
callback: (event: any) => boolean): () => void {
// Note: We are not using the EventsPlugin here as this is not needed
// to run our tests.
checkNoSyntheticProp(eventName, 'listener');
const el =
typeof target === 'string' ? getDOM().getGlobalEventTarget(this.document, target) : target;
const outsideHandler = (event: any) => this.ngZone.runGuarded(() => callback(event));
@ -171,6 +173,14 @@ class DefaultServerRendererV2 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 EmulatedEncapsulationServerRendererV2 extends DefaultServerRendererV2 {
private contentAttr: string;
private hostAttr: string;