From ed511e92195d9d3638aab3130f2684de3af27e33 Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Mon, 13 Nov 2017 17:12:25 +0800 Subject: [PATCH] Tree & Breadcrumb: fix setAttribute to undefined bug --- packages/breadcrumb/src/breadcrumb.vue | 4 +++- packages/tree/src/tree.vue | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/breadcrumb/src/breadcrumb.vue b/packages/breadcrumb/src/breadcrumb.vue index dc7a096ca..c5d0f021c 100644 --- a/packages/breadcrumb/src/breadcrumb.vue +++ b/packages/breadcrumb/src/breadcrumb.vue @@ -26,7 +26,9 @@ mounted() { const items = this.$el.querySelectorAll('.el-breadcrumb__item'); - items[items.length - 1].setAttribute('aria-current', 'page'); + if (items.length) { + items[items.length - 1].setAttribute('aria-current', 'page'); + } } }; diff --git a/packages/tree/src/tree.vue b/packages/tree/src/tree.vue index 43ad448c9..1a427c0c6 100644 --- a/packages/tree/src/tree.vue +++ b/packages/tree/src/tree.vue @@ -194,7 +194,7 @@ checkedItem[0].setAttribute('tabindex', 0); return; } - this.treeItems[0].setAttribute('tabindex', 0); + this.treeItems[0] && this.treeItems[0].setAttribute('tabindex', 0); }, handelKeydown(ev) { const currentItem = ev.target;