Skip to content

Commit

Permalink
Timeline: fix reverse broken (#16091)
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyoung authored and luckyCao committed Jun 18, 2019
1 parent 292b4e8 commit 3430835
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions packages/timeline/src/main.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
<template>
<ul class="el-timeline"
:class="{
'is-reverse': reverse
}">
<slot></slot>
</ul>
</template>

<script>
export default {
name: 'ElTimeline',
Expand All @@ -24,15 +15,19 @@
};
},
watch: {
reverse: {
handler(newVal) {
if (newVal) {
this.$slots.default = [...this.$slots.default].reverse();
}
},
immediate: true
render() {
const reverse = this.reverse;
const classes = {
'el-timeline': true,
'is-reverse': reverse
};
let slots = this.$slots.default || [];
if (reverse) {
slots = slots.reverse();
}
return (<ul class={ classes }>
{ slots }
</ul>);
}
};
</script>

0 comments on commit 3430835

Please sign in to comment.