Skip to content

[reactive-element] Initial changed properties can be inconsistent #4916

@sorvell

Description

@sorvell

Which package(s) are affected?

Lit Core (lit / lit-html / lit-element / reactive-element)

Description

Reactive properties defined via the static properties block v. the property decorator can have inconsistent initial changed values.

This is true for example, for properties defined via accessor or via custom get/set.

Reproduction

https://lit.dev/playground/#gist=9ea51856fe6b624f8dc1d37b62692dd4

See console output. All the of *j and *t properties should match.

Workaround

Hack fix:

static createProperty(name, options) {
  if (this.prototype.hasOwnProperty(name)) {
    options = {...options, wrapped: true};
  }
  super.createProperty(name, options);
}
  
_$changeProperty(name, oldValue, options) {
  oldValue = this.hasUpdated ? oldValue : undefined;
  super._$changeProperty(name, oldValue, options);
}

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

3.2.1

Browser/OS/Node environment

All

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions