diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-08-10 18:19:59 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-08-10 18:19:59 +0900 |
| commit | fff3c552e24f7d5b08252696bc55c8a1b9df3509 (patch) | |
| tree | be54aeecc330c8c5401cad452d6d4ad9e66c6813 /src | |
| parent | ハッシュタグ入力が空のときに#が付くのを修正 (diff) | |
| download | sharkey-fff3c552e24f7d5b08252696bc55c8a1b9df3509.tar.gz sharkey-fff3c552e24f7d5b08252696bc55c8a1b9df3509.tar.bz2 sharkey-fff3c552e24f7d5b08252696bc55c8a1b9df3509.zip | |
perf(client): use function for render slot to improve performance
See: https://forum.vuejs.org/t/how-to-avoid-non-function-value-encountered-for-default-slot-warning/107039
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/components/date-separated-list.vue | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/client/components/date-separated-list.vue b/src/client/components/date-separated-list.vue index 6a0c7f29f2..7a4cc5ef98 100644 --- a/src/client/components/date-separated-list.vue +++ b/src/client/components/date-separated-list.vue @@ -48,15 +48,7 @@ export default defineComponent({ render() { if (this.items.length === 0) return; - return h(this.$store.state.animation ? TransitionGroup : 'div', this.$store.state.animation ? { - class: 'sqadhkmv' + (this.noGap ? ' noGap _block' : ''), - name: 'list', - tag: 'div', - 'data-direction': this.direction, - 'data-reversed': this.reversed ? 'true' : 'false', - } : { - class: 'sqadhkmv' + (this.noGap ? ' noGap _block' : ''), - }, this.items.map((item, i) => { + const renderChildren = () => this.items.map((item, i) => { const el = this.$slots.default({ item: item })[0]; @@ -98,7 +90,19 @@ export default defineComponent({ return el; } } - })); + }); + + return h(this.$store.state.animation ? TransitionGroup : 'div', this.$store.state.animation ? { + class: 'sqadhkmv' + (this.noGap ? ' noGap _block' : ''), + name: 'list', + tag: 'div', + 'data-direction': this.direction, + 'data-reversed': this.reversed ? 'true' : 'false', + } : { + class: 'sqadhkmv' + (this.noGap ? ' noGap _block' : ''), + }, { + default: renderChildren + }); }, }); </script> |