2
0
mirror of https://github.com/tenrok/vue-context.git synced 2026-06-12 23:22:22 +03:00

Make localItemSelector reactive to changes from itemSelector prop

This commit is contained in:
Randall Wilk
2019-07-28 10:52:03 -05:00
parent 941e8f6939
commit bf58a429fd
2 changed files with 19 additions and 7 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+18 -6
View File
@@ -49,16 +49,12 @@ export default {
left: null, left: null,
show: false, show: false,
data: null, data: null,
localItemSelector: this.itemSelector localItemSelector: ''
}; };
}, },
created() { created() {
if (isArray(this.localItemSelector)) { this.localItemSelector = this.mapItemSelector(this.itemSelector);
this.localItemSelector = this.localItemSelector
.map(selector => `${selector}:not(.disabled):not([disabled])`)
.join(', ');
}
}, },
beforeDestroy() { beforeDestroy() {
@@ -126,6 +122,16 @@ export default {
return filterVisible(selectAll(this.localItemSelector, this.$el)); 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() { onClick() {
this.close(); this.close();
}, },
@@ -211,6 +217,12 @@ export default {
this.removeScrollEventListener(); this.removeScrollEventListener();
} }
}, },
itemSelector(selector, oldValue) {
if (selector !== oldValue) {
this.localItemSelector = this.mapItemSelector(selector);
}
}
}, },
render(h) { render(h) {