File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,10 @@ module.exports = {
90
90
var next
91
91
while ( next !== end ) {
92
92
next = cur . nextSibling
93
- if ( cur . contains && cur . contains ( c . $el ) ) {
93
+ if (
94
+ cur === c . $el ||
95
+ cur . contains && cur . contains ( c . $el )
96
+ ) {
94
97
return true
95
98
}
96
99
cur = next
Original file line number Diff line number Diff line change @@ -276,6 +276,56 @@ if (_.inBrowser) {
276
276
expect ( el . innerHTML ) . toBe ( markup )
277
277
}
278
278
} )
279
+
280
+ // #893 in IE textNodes do not have `contains` method
281
+ it ( 'call attach/detach: comparing textNodes in IE' , function ( done ) {
282
+ document . body . appendChild ( el )
283
+ var attachSpy = jasmine . createSpy ( 'attached' )
284
+ var detachSpy = jasmine . createSpy ( 'detached' )
285
+ var vm = new Vue ( {
286
+ el : el ,
287
+ data : {
288
+ show : true
289
+ } ,
290
+ template : '<template v-if="show"><test></test></template>' ,
291
+ components : {
292
+ test : {
293
+ template : 'hi' ,
294
+ replace : true ,
295
+ attached : attachSpy ,
296
+ detached : detachSpy
297
+ }
298
+ }
299
+ } )
300
+ assertMarkup ( )
301
+ assertCalls ( 1 , 0 )
302
+ vm . show = false
303
+ _ . nextTick ( function ( ) {
304
+ assertMarkup ( )
305
+ assertCalls ( 1 , 1 )
306
+ vm . show = true
307
+ _ . nextTick ( function ( ) {
308
+ assertMarkup ( )
309
+ assertCalls ( 2 , 1 )
310
+ vm . show = false
311
+ _ . nextTick ( function ( ) {
312
+ assertMarkup ( )
313
+ assertCalls ( 2 , 2 )
314
+ document . body . removeChild ( el )
315
+ done ( )
316
+ } )
317
+ } )
318
+ } )
319
+
320
+ function assertMarkup ( ) {
321
+ expect ( el . innerHTML ) . toBe ( vm . show ? 'hi' : '' )
322
+ }
323
+
324
+ function assertCalls ( attach , detach ) {
325
+ expect ( attachSpy . calls . count ( ) ) . toBe ( attach )
326
+ expect ( detachSpy . calls . count ( ) ) . toBe ( detach )
327
+ }
328
+ } )
279
329
280
330
} )
281
331
}
You can’t perform that action at this time.
0 commit comments