@@ -51,7 +51,8 @@ export default {
51
51
},
52
52
data () {
53
53
return {
54
- mdcDialog: null
54
+ mdcDialog: null ,
55
+ slotOberserver: null
55
56
}
56
57
},
57
58
computed: {
@@ -75,32 +76,38 @@ export default {
75
76
}
76
77
},
77
78
mounted () {
78
- let vm = this
79
+ this .updateSlots ()
80
+ this .slotOberserver = new MutationObserver ( () => this .updateSlots ())
81
+ this .slotOberserver .observe (this .$el , {
82
+ childList: true ,
83
+ subtree: true
84
+ })
79
85
80
- if (vm .$slots .acceptButton ) {
81
- vm .$slots .acceptButton .map (n => {
82
- n .elm .classList .add (' mdc-dialog__footer__button' )
83
- n .elm .classList .add (' mdc-dialog__footer__button--accept' )
84
- })
85
- }
86
- if (vm .$slots .cancelButton ) {
87
- vm .$slots .cancelButton .map (n => {
88
- n .elm .classList .add (' mdc-dialog__footer__button' )
89
- n .elm .classList .add (' mdc-dialog__footer__button--cancel' )
90
- })
91
- }
92
- if (vm .$slots .dialogButton ) {
93
- vm .$slots .dialogButton .map (n => {
94
- n .elm .classList .add (' mdc-dialog__footer__button' )
95
- })
96
- }
97
-
98
- vm .mdcDialog = MDCDialog .attachTo (this .$el )
86
+ this .mdcDialog = MDCDialog .attachTo (this .$el )
99
87
},
100
88
beforeDestroy () {
101
89
this .mdcDialog .destroy ()
102
90
},
103
91
methods: {
92
+ updateSlots () {
93
+ if (this .$slots .acceptButton ) {
94
+ this .$slots .acceptButton .map (n => {
95
+ n .elm .classList .add (' mdc-dialog__footer__button' )
96
+ n .elm .classList .add (' mdc-dialog__footer__button--accept' )
97
+ })
98
+ }
99
+ if (this .$slots .cancelButton ) {
100
+ this .$slots .cancelButton .map (n => {
101
+ n .elm .classList .add (' mdc-dialog__footer__button' )
102
+ n .elm .classList .add (' mdc-dialog__footer__button--cancel' )
103
+ })
104
+ }
105
+ if (this .$slots .dialogButton ) {
106
+ this .$slots .dialogButton .map (n => {
107
+ n .elm .classList .add (' mdc-dialog__footer__button' )
108
+ })
109
+ }
110
+ },
104
111
onAccept () {
105
112
this .model = false
106
113
this .$emit (' accept' )
0 commit comments