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
This commit is contained in:
Vikram Subramanian 2018-05-10 19:35:19 -07:00 committed by Matias Niemelä
parent cfde36da84
commit d4b8b24406
1 changed files with 3 additions and 1 deletions

View File

@ -131,7 +131,9 @@ export function createCustomElement<P>(
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();