Skip to content

Commit c0ea123

Browse files
committed
style: fix eslint issues with old files
1 parent 0081a4f commit c0ea123

File tree

4 files changed

+77
-38
lines changed

4 files changed

+77
-38
lines changed

src/components/MdApp/MdApp.vue

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414
return componentOptions && componentTypes.includes(componentOptions.tag)
1515
}
1616
17+
function isRightDrawer ({ mdRight }) {
18+
return mdRight === '' || !!mdRight
19+
}
20+
21+
function createRightDrawer (isMdRight) {
22+
if (isMdRight) {
23+
const drawerRightPrevious = createElement(MdDrawerRightPrevious, { props: {...child.data.attrs}})
24+
drawerRightPrevious.data.slot = 'md-app-drawer-right-previous'
25+
slots.push(drawerRightPrevious)
26+
}
27+
}
28+
29+
function shouldRenderSlot (data, componentOptions) {
30+
rreturn (data && componentTypes.includes(data.slot)) || isValidChild(componentOptions)
31+
}
32+
1733
function buildSlots (children, context, functionalContext, options, createElement) {
1834
let slots = []
1935
@@ -24,29 +40,25 @@
2440
const data = child.data
2541
const componentOptions = child.componentOptions
2642
27-
if ((data && componentTypes.includes(data.slot)) || isValidChild(componentOptions)) {
43+
if (shouldRenderSlot(data, componentOptions)) {
2844
child.data.slot = data.slot || componentOptions.tag
2945
3046
if (componentOptions.tag === 'md-app-drawer') {
47+
const isRightDrawer = isRightDrawer(componentOptions.propsData)
48+
3149
if (hasDrawer) {
3250
Vue.util.warn(`There shouldn't be more than one drawer in a MdApp at one time.`)
3351
return
3452
}
3553
3654
hasDrawer = true
37-
let nativeMdRight = componentOptions.propsData.mdRight
38-
let mdRight = nativeMdRight === '' || !!nativeMdRight
39-
child.data.slot += `-${mdRight ? 'right' : 'left'}`
55+
child.data.slot += `-${isRightDrawer ? 'right' : 'left'}`
4056
child.key = JSON.stringify({
4157
'persistent': child.data.attrs['md-persistent'],
4258
'permanent': child.data.attrs['md-permanent']
4359
})
4460
45-
if (mdRight) {
46-
const drawerRightPrevious = createElement(MdDrawerRightPrevious, { props: {...child.data.attrs}})
47-
drawerRightPrevious.data.slot = 'md-app-drawer-right-previous'
48-
slots.push(drawerRightPrevious)
49-
}
61+
createRightDrawer(isRightDrawer)
5062
}
5163
5264
child.data.provide = options.Ctor.options.provide

src/components/MdBadge/MdBadge.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@
4040
return !!this.$slots.default
4141
},
4242
badgeClasses () {
43-
const staticClass = this.$vnode.data.staticClass ?
44-
this.$vnode.data.staticClass.split(' ').filter(val => val).reduce((result, key) => {
45-
result[key] = true
46-
return result
47-
}, {}) : {}
48-
43+
const staticClass = this.getStaticClass()
4944
const dynamicClass = this.$vnode.data.class
5045
5146
return {
@@ -63,6 +58,20 @@
6358
...style
6459
}
6560
}
61+
},
62+
methods: {
63+
getStaticClass () {
64+
const staticClass = this.$vnode.data.staticClass
65+
66+
function filterClasses () {
67+
staticClass.split(' ').filter(val => val).reduce((result, key) => {
68+
result[key] = true
69+
return result
70+
}, {})
71+
}
72+
73+
return staticClass ? filterClasses() : {}
74+
}
6675
}
6776
})
6877
</script>

src/components/MdMenu/MdMenuContent.vue

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,21 @@
193193
194194
return Boolean(alignTrigger || offsetY || offsetX)
195195
},
196+
isMenu ({ target }) {
197+
return this.MdMenu.$el ? this.MdMenu.$el.contains(target) : false
198+
},
199+
isMenuContentEl ({ target }) {
200+
return this.$refs.menu ? this.$refs.menu.contains(target) : false
201+
},
202+
isBackdropExpectMenu ($event) {
203+
return !this.$el.contains($event.target) && !this.isMenu($event)
204+
},
196205
createClickEventObserver () {
197206
if (document) {
198207
this.MdMenu.bodyClickObserver = new MdObserveEvent(document.body, 'click', $event => {
199208
$event.stopPropagation()
200-
let isMdMenu = this.MdMenu.$el ? this.MdMenu.$el.contains($event.target) : false
201-
let isMenuContentEl = this.$refs.menu ? this.$refs.menu.contains($event.target) : false
202-
let onBackdropExpectMenu = !this.$el.contains($event.target) && !isMenuContentEl
203-
if (!isMdMenu && (this.MdMenu.closeOnClick || onBackdropExpectMenu)) {
209+
210+
if (!this.isMenu($event) && (this.MdMenu.closeOnClick || this.isBackdropExpectMenu($event))) {
204211
this.MdMenu.active = false
205212
this.MdMenu.bodyClickObserver.destroy()
206213
this.MdMenu.windowResizeObserver.destroy()
@@ -217,19 +224,26 @@
217224
},
218225
keyNavigation (event) {
219226
switch (event.key) {
220-
case 'ArrowUp':
221-
event.preventDefault()
222-
this.setHighlight('up')
223-
break
224-
case 'ArrowDown':
225-
event.preventDefault()
226-
this.setHighlight('down')
227-
break
228-
case 'Enter': this.setSelection()
229-
break
230-
case 'Space': this.setSelection()
231-
break
232-
case 'Escape': this.onEsc()
227+
case 'ArrowUp':
228+
event.preventDefault()
229+
this.setHighlight('up')
230+
break
231+
232+
case 'ArrowDown':
233+
event.preventDefault()
234+
this.setHighlight('down')
235+
break
236+
237+
case 'Enter':
238+
this.setSelection()
239+
break
240+
241+
case 'Space':
242+
this.setSelection()
243+
break
244+
245+
case 'Escape':
246+
this.onEsc()
233247
}
234248
},
235249
createResizeObserver () {

src/components/MdTable/MdTable.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,17 @@
235235
},
236236
'MdTable.selectedItems' (val, old) {
237237
let changed = (() => {
238-
let isValEmpty = !val || val.length === 0
239-
let isOldEmpty = !old || old.length === 0
238+
let isValEmpty = this.isEmpty(val)
239+
let isOldEmpty = this.isEmpty(old)
240+
let hasValues = isValEmpty && isOldEmpty
240241
241-
if (isValEmpty && isOldEmpty) {
242+
if (hasValues) {
242243
return false
243-
} else if (!isValEmpty && !isOldEmpty) {
244+
} else if (!hasValues) {
244245
return (val.length !== old.length) ? true : !val.every((item, index) => item == old[index])
245-
} else {
246-
return true
247246
}
247+
248+
return true
248249
})()
249250
250251
if (changed) {
@@ -261,6 +262,9 @@
261262
}
262263
},
263264
methods: {
265+
isEmpty (value) {
266+
return !value || value.length === 0
267+
},
264268
emitEvent (eventName, value) {
265269
this.$emit(eventName, value)
266270
},

0 commit comments

Comments
 (0)