Skip to content

Commit

Permalink
fix(fast-element): always reflect latest value to attribute (microsof…
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect authored Apr 9, 2020
1 parent 9a6f464 commit 48cca59
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/fast-element/src/attributes.ts
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ export class AttributeDefinition {
if (oldValue !== newValue) {
element[this.fieldName] = newValue;

this.tryReflectToAttribute(element, newValue, converter);
this.tryReflectToAttribute(element);

if (this.hasCallback) {
element[this.callbackName](oldValue, newValue);
@@ -113,11 +113,7 @@ export class AttributeDefinition {
this.guards.delete(element);
}

private tryReflectToAttribute(
element: HTMLElement,
newValue: any,
converter?: ValueConverter
) {
private tryReflectToAttribute(element: HTMLElement) {
const mode = this.mode;
const guards = this.guards;

@@ -128,16 +124,19 @@ export class AttributeDefinition {
DOM.queueUpdate(() => {
guards.add(element);

const latestValue = element[this.fieldName];

switch (mode) {
case "reflect":
const converter = this.converter;
DOM.setAttribute(
element,
this.attribute,
converter !== void 0 ? converter.toView(newValue) : newValue
converter !== void 0 ? converter.toView(latestValue) : latestValue
);
break;
case "boolean":
DOM.setBooleanAttribute(element, this.attribute, newValue);
DOM.setBooleanAttribute(element, this.attribute, latestValue);
break;
}

0 comments on commit 48cca59

Please sign in to comment.