Skip to content

Commit

Permalink
fix: don't throw on requestContentUpdate before attaching (#2995)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Nov 9, 2021
1 parent bfc3fa0 commit 99691fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/select/src/vaadin-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
*/
requestContentUpdate() {
if (!this._overlayElement) {
return;
}

this._overlayElement.requestContentUpdate();

// Ensure menu element is set
Expand Down
5 changes: 5 additions & 0 deletions packages/select/test/renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ describe('renderer', () => {
};
});

it('should not throw when requesting content update before attaching to the DOM', () => {
const select = document.createElement('vaadin-select');
expect(() => select.requestContentUpdate()).not.to.throw(Error);
});

it('should run renderers when requesting content update', () => {
select.renderer = sinon.spy();
select.opened = true;
Expand Down

0 comments on commit 99691fc

Please sign in to comment.