Skip to content

Commit 513dd05

Browse files
committed
Update validation on disabled/readonly attr change
1 parent e46aa38 commit 513dd05

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/components/mixins/validation.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export default {
2424
},
2525
mounted() {
2626
this.setValidatorLanguage();
27-
this.updateValidation()
27+
this.updateValidation();
28+
this.observeElementMutations();
2829
},
2930
watch: {
3031
// Triggered whenever the v-model is updated
@@ -52,6 +53,20 @@ export default {
5253
}
5354
},
5455
methods: {
56+
observeElementMutations() {
57+
new MutationObserver(this.handleMutations).observe(this.$el, {
58+
attributes: true,
59+
attributeFilter: ['readonly', 'disabled'],
60+
subtree: true
61+
});
62+
},
63+
handleMutations(mutations) {
64+
mutations.forEach(mutation => {
65+
if (mutation.type == "attributes") {
66+
this.updateValidation()
67+
}
68+
});
69+
},
5570
setValidatorLanguage() {
5671
let globalObject = typeof window === 'undefined' ? global : window;
5772

0 commit comments

Comments
 (0)