File tree Expand file tree Collapse file tree 4 files changed +17
-11
lines changed Expand file tree Collapse file tree 4 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,8 @@ describe('ViewNode', () => {
241
241
expect ( prevChildNode . nextSibling ) . toEqual ( nextChildNode )
242
242
expect ( nextChildNode . prevSibling ) . toEqual ( prevChildNode )
243
243
expect ( childNode . parentNode ) . toBeNull ( )
244
+ expect ( childNode . prevSibling ) . toBeNull ( )
245
+ expect ( childNode . nextSibling ) . toBeNull ( )
244
246
} )
245
247
246
248
test ( 'nativeView can be set once' , ( ) => {
Original file line number Diff line number Diff line change @@ -246,6 +246,12 @@ export default class ViewNode {
246
246
childNode . nextSibling . prevSibling = childNode . prevSibling
247
247
}
248
248
249
+ // reset the prevSibling and nextSibling. If not, a keep-alived component will
250
+ // still have a filled nextSibling attribute so vue will not
251
+ // insert the node again to the parent. See #220
252
+ childNode . prevSibling = null
253
+ childNode . nextSibling = null
254
+
249
255
this . childNodes = this . childNodes . filter ( node => node !== childNode )
250
256
251
257
viewUtil . removeChild ( this , childNode )
Original file line number Diff line number Diff line change @@ -41,19 +41,19 @@ export function appendChild(node, child) {
41
41
}
42
42
43
43
export function parentNode ( node ) {
44
- trace ( `ParentNode(${ node } )` )
44
+ trace ( `ParentNode(${ node } ) -> ${ node . parentNode } ` )
45
45
46
46
return node . parentNode
47
47
}
48
48
49
49
export function nextSibling ( node ) {
50
- trace ( `NextSibling(${ node } )` )
50
+ trace ( `NextSibling(${ node } ) -> ${ node . nextSibling } ` )
51
51
52
52
return node . nextSibling
53
53
}
54
54
55
55
export function tagName ( elementNode ) {
56
- trace ( `TagName(${ elementNode } )` )
56
+ trace ( `TagName(${ elementNode } ) -> ${ elementNode . tagName } ` )
57
57
58
58
return elementNode . tagName
59
59
}
Original file line number Diff line number Diff line change @@ -5,14 +5,12 @@ Vue.config.silent = false
5
5
6
6
const CompButton = {
7
7
template : `
8
- <Button @tap="counter++" >{{label}}: {{counter}}</Button>
8
+ <Button>{{label}}: {{counter}}</Button>
9
9
` ,
10
10
name : 'CompButton' ,
11
- props : [ 'label' ] ,
12
- data ( ) {
13
- return {
14
- counter : 0
15
- }
11
+ props : [ 'label' , 'counter' ] ,
12
+ destroyed ( ) {
13
+ console . log ( 'Component destroyed. This should not happen' )
16
14
}
17
15
}
18
16
@@ -27,8 +25,8 @@ new Vue({
27
25
<StackLayout>
28
26
<Button @tap="counter++">{{counter}}</Button>
29
27
<keep-alive>
30
- <CompButton v-if="counter % 2" key="odd" label="Odd" />
31
- <CompButton v-else key="even" label="Even" />
28
+ <CompButton v-if="counter % 2" key="odd" label="Odd" :counter="counter" />
29
+ <CompButton v-else key="even" label="Even" :counter="counter" />
32
30
</keep-alive>
33
31
</StackLayout>
34
32
</Page>
You can’t perform that action at this time.
0 commit comments