Skip to content

Commit 697c3a7

Browse files
committed
Add getUpdateComplete() for forward-compat with LitElement 3.0
1 parent 748f1e4 commit 697c3a7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2222
### Changed
2323

2424
* Added the `@state()` decorator as an alias for `@internalProperty()`, and deprecated `@internalProperty()` which will be renamed to `@state` in lit-element 3.0. [#1162](https://github.com/Polymer/lit-element/issues/1162).
25+
* Added `UpdatingElement.prototype.getUpdateComplete()` and deprecated `_getUpdateComplete()` for forward compibility with lit-element 3.0.
2526

2627
### Added
2728
* Adds a `static shadowRootOptions` property for specifying shadow root options. This is a slightly simpler alternative to implementing a custom `createRenderRoot` method [#1147](https://github.com/Polymer/lit-element/issues/1147).

src/lib/updating-element.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,30 @@ export abstract class UpdatingElement extends HTMLElement {
832832
* await this._myChild.updateComplete;
833833
* }
834834
* }
835+
* @deprecated Override `getUpdateComplete()` instead for forward
836+
* compatibility with `lit-element` 3.0 / `@lit/reactive-element`.
835837
*/
836838
protected _getUpdateComplete() {
839+
return this.getUpdateComplete();
840+
}
841+
842+
/**
843+
* Override point for the `updateComplete` promise.
844+
*
845+
* It is not safe to override the `updateComplete` getter directly due to a
846+
* limitation in TypeScript which means it is not possible to call a
847+
* superclass getter (e.g. `super.updateComplete.then(...)`) when the target
848+
* language is ES5 (https://github.com/microsoft/TypeScript/issues/338).
849+
* This method should be overridden instead. For example:
850+
*
851+
* class MyElement extends LitElement {
852+
* async getUpdateComplete() {
853+
* await super.getUpdateComplete();
854+
* await this._myChild.updateComplete;
855+
* }
856+
* }
857+
*/
858+
protected getUpdateComplete() {
837859
return this._updatePromise;
838860
}
839861

0 commit comments

Comments
 (0)