From 11f7e763c8d19499ee240d9bc5438c1344a9eb8b Mon Sep 17 00:00:00 2001 From: Pwntus Date: Sat, 19 May 2018 00:13:02 +0200 Subject: [PATCH 1/2] fix(MdApp): TypeError: child.data.attrs is undefined --- src/components/MdApp/MdApp.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/MdApp/MdApp.vue b/src/components/MdApp/MdApp.vue index 7f697777c..22d5078c7 100644 --- a/src/components/MdApp/MdApp.vue +++ b/src/components/MdApp/MdApp.vue @@ -37,6 +37,7 @@ if (children) { children.forEach(child => { + /* eslint-enable */ const data = child.data const componentOptions = child.componentOptions @@ -53,9 +54,10 @@ hasDrawer = true child.data.slot += `-${isRight ? 'right' : 'left'}` + const attrs = child.data.attrs child.key = JSON.stringify({ - 'persistent': child.data.attrs['md-persistent'], - 'permanent': child.data.attrs['md-permanent'] + 'persistent': attrs && attrs['md-persistent'], + 'permanent': attrs && attrs['md-permanent'] }) createRightDrawer(isRight) From e459c84f94b372ee39ccb34e8b978e1852c7ef3b Mon Sep 17 00:00:00 2001 From: Pwntus Date: Sat, 19 May 2018 01:58:16 +0200 Subject: [PATCH 2/2] fix(MdApp): add generateAttrKeys function to adhere ESLint complexity limit of 6 (#1741) --- src/components/MdApp/MdApp.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/MdApp/MdApp.vue b/src/components/MdApp/MdApp.vue index 22d5078c7..3d6cd9a42 100644 --- a/src/components/MdApp/MdApp.vue +++ b/src/components/MdApp/MdApp.vue @@ -30,6 +30,13 @@ return (data && componentTypes.includes(data.slot)) || isValidChild(componentOptions) } + function generateAttrKeys (attrs) { + return JSON.stringify({ + 'persistent': attrs && attrs['md-persistent'], + 'permanent': attrs && attrs['md-permanent'] + }) + } + function buildSlots (children, context, functionalContext, options, createElement) { let slots = [] @@ -54,11 +61,7 @@ hasDrawer = true child.data.slot += `-${isRight ? 'right' : 'left'}` - const attrs = child.data.attrs - child.key = JSON.stringify({ - 'persistent': attrs && attrs['md-persistent'], - 'permanent': attrs && attrs['md-permanent'] - }) + child.key = generateAttrKeys(data.attrs) createRightDrawer(isRight) }