From 933a3a920d19b1accb9171024279f18da5bdd03a Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Fri, 20 Apr 2018 22:49:56 -0400 Subject: [PATCH] [wip] fix prop normalization This (along with some changes to Ember that I will also PR) solves https://github.com/emberjs/ember.js/issues/16311 and https://github.com/emberjs/ember.js/issues/16477 This is not ready to go yet because I'm also going to refactor so we don't compute the normalized property name twice. --- .../runtime/lib/vm/attributes/dynamic.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/@glimmer/runtime/lib/vm/attributes/dynamic.ts b/packages/@glimmer/runtime/lib/vm/attributes/dynamic.ts index d8f13e0cb8..c79f85710f 100644 --- a/packages/@glimmer/runtime/lib/vm/attributes/dynamic.ts +++ b/packages/@glimmer/runtime/lib/vm/attributes/dynamic.ts @@ -81,20 +81,27 @@ export class SimpleDynamicAttribute extends DynamicAttribute { } export class DefaultDynamicProperty extends DynamicAttribute { + private normalizedName: string; + + constructor(attribute: Attribute) { + super(attribute); + let { element, name } = this.attribute; + this.normalizedName = normalizeProperty(element, name).normalized; + } + value: Opaque; set(dom: ElementBuilder, value: Opaque, _env: Environment): void { if (value !== null && value !== undefined) { - let { name } = this.attribute; this.value = value; - dom.__setProperty(name, value); + dom.__setProperty(this.normalizedName, value); } } update(value: Opaque, _env: Environment): void { - let { element, name } = this.attribute; + let { element } = this.attribute; if (this.value !== value) { - element[name] = this.value = value; + element[this.normalizedName] = this.value = value; if (value === null || value === undefined) { this.removeAttribute(); @@ -106,12 +113,12 @@ export class DefaultDynamicProperty extends DynamicAttribute { protected removeAttribute() { // TODO this sucks but to preserve properties first and to meet current // semantics we must do this. - let { element, name, namespace } = this.attribute; + let { element, namespace } = this.attribute; if (namespace) { - element.removeAttributeNS(namespace, name); + element.removeAttributeNS(namespace, this.normalizedName); } else { - element.removeAttribute(name); + element.removeAttribute(this.normalizedName); } } }