From d4b8b2440673049c58d51b0ae4afceb028d62cc0 Mon Sep 17 00:00:00 2001 From: Vikram Subramanian Date: Thu, 10 May 2018 19:35:19 -0700 Subject: [PATCH] fix(elements): prevent closure renaming of platform properties (#23843) Closure compiler with type based optimizations has a bug where externs for inherited static fields are not being honored. For Angular Elements this meant that 'observedAttributes' static field which is marked as an extern for the base HTMLElement class was getting renamed. This commit works around the bug by using quoted access of 'observedAttributes' that explicitly prevents the renaming. PR Close #23843 --- packages/elements/src/create-custom-element.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/elements/src/create-custom-element.ts b/packages/elements/src/create-custom-element.ts index 34595baa34..ce70f3ae7a 100644 --- a/packages/elements/src/create-custom-element.ts +++ b/packages/elements/src/create-custom-element.ts @@ -131,7 +131,9 @@ export function createCustomElement

( const attributeToPropertyInputs = getDefaultAttributeToPropertyInputs(inputs); class NgElementImpl extends NgElement { - static readonly observedAttributes = Object.keys(attributeToPropertyInputs); + // Work around a bug in closure typed optimizations(b/79557487) where it is not honoring static + // field externs. So using quoted access to explicitly prevent renaming. + static readonly['observedAttributes'] = Object.keys(attributeToPropertyInputs); constructor(injector?: Injector) { super();