From 4c1e07783360a8045277b3db8610881351964950 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 3 May 2021 11:32:59 -0400 Subject: [PATCH] fixes #425 --- docs/resources/changelog.md | 1 + src/internal/decorators.ts | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/resources/changelog.md b/docs/resources/changelog.md index a9e933bd..8488ac70 100644 --- a/docs/resources/changelog.md +++ b/docs/resources/changelog.md @@ -8,6 +8,7 @@ _During the beta period, these restrictions may be relaxed in the event of a mis ## Next +- Fixed a bug where setting properties before an element was defined would render incorrectly [#425](https://github.com/shoelace-style/shoelace/issues/425) - Improved a11y in `sl-progress-ring` - Updated React docs to use [`@shoelace-style/react`](https://github.com/shoelace-style/react) - Updated NextJS docs [#434](https://github.com/shoelace-style/shoelace/pull/434) diff --git a/src/internal/decorators.ts b/src/internal/decorators.ts index 08b10761..a30c8e20 100644 --- a/src/internal/decorators.ts +++ b/src/internal/decorators.ts @@ -63,8 +63,7 @@ export class EventEmitter { // @watch decorator // -// Runs after an observed property changes, e.g. @property or @state. This will only run after the first -// update, so initial attribute => property mappings will not trigger the watch handler. +// Runs after an observed property changes, e.g. @property or @state. // // Note that changing props in a watch handler *will* trigger a rerender. To make pre-update changes to observed // properties, use the `update()` method instead. @@ -80,7 +79,7 @@ export function watch(propName: string) { const { updated } = protoOrDescriptor; protoOrDescriptor.updated = function (changedProps: Map) { - if (this.__hasBeenUpdated && changedProps.has(propName)) { + if (changedProps.has(propName)) { const oldValue = changedProps.get(propName); const newValue = this[propName]; @@ -90,7 +89,6 @@ export function watch(propName: string) { } updated.call(this, changedProps); - this.__hasBeenUpdated = true; }; }; }