Skip to content

Commit b22dab3

Browse files
committed
Don't update the DOM if the toggle has been removed
Currently, if the toggle causes the element to be removed from the DOM, the code that updates the DOM fails with `TypeError: Cannot read property 'querySelector' of null`
1 parent 0b8ecca commit b22dab3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

addon/components/x-toggle.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export default class XToggle extends Component {
5454

5555
@action
5656
toggleSwitch(value) {
57+
// Prevent re-renders when the element is cleaning up (which cause errors).
58+
if (this.isDestroyed || this.isDestroying) return
59+
5760
let onToggle = this.args.onToggle;
5861
let disabled = this.disabled;
5962

0 commit comments

Comments
 (0)