@@ -86,6 +86,7 @@ export default class BindingWrapper {
86
86
const { parent } = this ;
87
87
88
88
const update_conditions : any [ ] = this . needs_lock ? [ x `!${ lock } ` ] : [ ] ;
89
+ const mount_conditions : any [ ] = [ ] ;
89
90
90
91
const dependency_array = [ ...this . node . expression . dependencies ] ;
91
92
@@ -103,6 +104,7 @@ export default class BindingWrapper {
103
104
104
105
// model to view
105
106
let update_dom = get_dom_updater ( parent , this ) ;
107
+ let mount_dom = update_dom ;
106
108
107
109
// special cases
108
110
switch ( this . node . name ) {
@@ -122,13 +124,19 @@ export default class BindingWrapper {
122
124
123
125
case 'textContent' :
124
126
update_conditions . push ( x `${ this . snippet } !== ${ parent . var } .textContent` ) ;
127
+ mount_conditions . push ( x `${ this . snippet } !== void 0` ) ;
125
128
break ;
126
129
127
130
case 'innerHTML' :
128
131
update_conditions . push ( x `${ this . snippet } !== ${ parent . var } .innerHTML` ) ;
132
+ mount_conditions . push ( x `${ this . snippet } !== void 0` ) ;
129
133
break ;
130
134
131
135
case 'currentTime' :
136
+ update_conditions . push ( x `!@_isNaN(${ this . snippet } )` ) ;
137
+ mount_dom = null ;
138
+ break ;
139
+
132
140
case 'playbackRate' :
133
141
case 'volume' :
134
142
update_conditions . push ( x `!@_isNaN(${ this . snippet } )` ) ;
@@ -142,12 +150,14 @@ export default class BindingWrapper {
142
150
143
151
update_conditions . push ( x `${ last } !== (${ last } = ${ this . snippet } )` ) ;
144
152
update_dom = b `${ parent . var } [${ last } ? "pause" : "play"]();` ;
153
+ mount_dom = null ;
145
154
break ;
146
155
}
147
156
148
157
case 'value' :
149
158
if ( parent . node . get_static_attribute_value ( 'type' ) === 'file' ) {
150
159
update_dom = null ;
160
+ mount_dom = null ;
151
161
}
152
162
}
153
163
@@ -165,13 +175,18 @@ export default class BindingWrapper {
165
175
}
166
176
}
167
177
168
- if ( this . node . name === 'innerHTML' || this . node . name === 'textContent' ) {
169
- block . chunks . mount . push ( b `
170
- if (${ this . snippet } !== void 0) {
171
- ${ update_dom }
172
- }` ) ;
173
- } else if ( ! / ( c u r r e n t T i m e | p a u s e d ) / . test ( this . node . name ) ) {
174
- block . chunks . mount . push ( update_dom ) ;
178
+ if ( mount_dom ) {
179
+ if ( mount_conditions . length > 0 ) {
180
+ const condition = mount_conditions . reduce ( ( lhs , rhs ) => x `${ lhs } && ${ rhs } ` ) ;
181
+
182
+ block . chunks . mount . push ( b `
183
+ if (${ condition } ) {
184
+ ${ mount_dom }
185
+ }
186
+ ` ) ;
187
+ } else {
188
+ block . chunks . mount . push ( mount_dom ) ;
189
+ }
175
190
}
176
191
}
177
192
}
0 commit comments