X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/e711290d8b1ce06b38e0560248806e8de2077870..refs/pull/4955/head:/resources/js/components/expand-toggle.js diff --git a/resources/js/components/expand-toggle.js b/resources/js/components/expand-toggle.js index 76928623d..0d2018b9d 100644 --- a/resources/js/components/expand-toggle.js +++ b/resources/js/components/expand-toggle.js @@ -3,7 +3,7 @@ import {Component} from './component'; export class ExpandToggle extends Component { - setup(elem) { + setup() { this.targetSelector = this.$opts.targetSelector; this.isOpen = this.$opts.isOpen === 'true'; this.updateEndpoint = this.$opts.updateEndpoint; @@ -25,7 +25,8 @@ export class ExpandToggle extends Component { const matchingElems = document.querySelectorAll(this.targetSelector); for (const match of matchingElems) { - this.isOpen ? this.close(match) : this.open(match); + const action = this.isOpen ? this.close : this.open; + action(match); } this.isOpen = !this.isOpen;