-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(weex): partially support lifecycles of virtual component (#7242)
Update the `_init` and `_update` logic to partially support lifecycles. Add test cases for testing the lifecycle hooks and data update.
- Loading branch information
1 parent
d544d05
commit 661bfe5
Showing
13 changed files
with
229 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template recyclable="true"> | ||
<div> | ||
<text>{{number}}</text> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
module.exports = { | ||
data () { | ||
return { number: 0 } | ||
}, | ||
beforeCreate () { | ||
try { __lifecycles.push('beforeCreate ' + this.number) } catch (e) {} | ||
}, | ||
created () { | ||
try { __lifecycles.push('created ' + this.number) } catch (e) {} | ||
this.number++ | ||
}, | ||
beforeMount () { | ||
try { __lifecycles.push('beforeMount ' + this.number) } catch (e) {} | ||
}, | ||
mounted () { | ||
try { __lifecycles.push('mounted ' + this.number) } catch (e) {} | ||
this.number++ | ||
}, | ||
beforeUpdate () { | ||
try { __lifecycles.push('beforeUpdate ' + this.number) } catch (e) {} | ||
}, | ||
updated () { | ||
try { __lifecycles.push('updated ' + this.number) } catch (e) {} | ||
}, | ||
beforeDestroy () { | ||
try { __lifecycles.push('beforeDestroy ' + this.number) } catch (e) {} | ||
}, | ||
destroyed () { | ||
try { __lifecycles.push('destroyed ' + this.number) } catch (e) {} | ||
} | ||
} | ||
</script> |
29 changes: 29 additions & 0 deletions
29
test/weex/cases/recycle-list/components/stateful-lifecycle.vdom.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
({ | ||
type: 'recycle-list', | ||
attr: { | ||
append: 'tree', | ||
listData: [ | ||
{ type: 'X' }, | ||
{ type: 'X' } | ||
], | ||
templateKey: 'type', | ||
alias: 'item' | ||
}, | ||
children: [{ | ||
type: 'cell-slot', | ||
attr: { append: 'tree', templateType: 'X' }, | ||
children: [{ | ||
type: 'div', | ||
attr: { | ||
'@isComponentRoot': true, | ||
'@componentProps': {} | ||
}, | ||
children: [{ | ||
type: 'text', | ||
attr: { | ||
value: { '@binding': 'number' } | ||
} | ||
}] | ||
}] | ||
}] | ||
}) |
21 changes: 21 additions & 0 deletions
21
test/weex/cases/recycle-list/components/stateful-lifecycle.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template> | ||
<recycle-list :list-data="longList" template-key="type" alias="item"> | ||
<cell-slot template-type="X"> | ||
<lifecycle></lifecycle> | ||
</cell-slot> | ||
</recycle-list> | ||
</template> | ||
|
||
<script> | ||
// require('./lifecycle.vue') | ||
module.exports = { | ||
data () { | ||
return { | ||
longList: [ | ||
{ type: 'X' }, | ||
{ type: 'X' } | ||
] | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters