Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
Make localItemSelector reactive to changes from itemSelector prop
Browse files Browse the repository at this point in the history
  • Loading branch information
rawilk committed Jul 28, 2019
1 parent 941e8f6 commit bf58a42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/js/vue-context.js

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions src/js/vue-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,12 @@ export default {
left: null,
show: false,
data: null,
localItemSelector: this.itemSelector
localItemSelector: ''
};
},

created() {
if (isArray(this.localItemSelector)) {
this.localItemSelector = this.localItemSelector
.map(selector => `${selector}:not(.disabled):not([disabled])`)
.join(', ');
}
this.localItemSelector = this.mapItemSelector(this.itemSelector);
},

beforeDestroy() {
Expand Down Expand Up @@ -126,6 +122,16 @@ export default {
return filterVisible(selectAll(this.localItemSelector, this.$el));
},

mapItemSelector(itemSelector) {
if (isArray(itemSelector)) {
itemSelector = itemSelector
.map(selector => `${selector}:not(.disabled):not([disabled])`)
.join(', ');
}

return itemSelector;
},

onClick() {
this.close();
},
Expand Down Expand Up @@ -211,6 +217,12 @@ export default {
this.removeScrollEventListener();
}
},

itemSelector(selector, oldValue) {
if (selector !== oldValue) {
this.localItemSelector = this.mapItemSelector(selector);
}
}
},

render(h) {
Expand Down

0 comments on commit bf58a42

Please sign in to comment.