Skip to content

Commit 4cbb036

Browse files
committed
fix(MdList): add full support to router-link
1 parent e091c6f commit 4cbb036

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import mountTemplate from 'test/utils/mountTemplate'
2-
import MdList from './MdList.vue'
2+
import MdListItem from './MdListItem.vue'
33

4-
test('should render the list', async () => {
5-
const template = '<md-list>Lorem ipsum</md-list>'
6-
const wrapper = await mountTemplate(MdList, template)
4+
test('should render the list item', async () => {
5+
const template = '<md-list-item>Lorem ipsum</md-list-item>'
6+
const wrapper = await mountTemplate(MdListItem, template)
77

8-
expect(wrapper.hasClass('md-list')).toBe(true)
9-
expect(wrapper.text()).toBe('Lorem ipsum')
8+
expect(wrapper.hasClass('md-list-item')).toBe(true)
9+
expect(wrapper.text().trim()).toBe('Lorem ipsum')
1010
})
1111

1212
test('should render the theme class', async () => {
13-
const template = '<md-list md-theme="alt">Lorem ipsum</md-list>'
14-
const wrapper = await mountTemplate(MdList, template)
13+
const template = '<md-list-item md-theme="alt">Lorem ipsum</md-list-item>'
14+
const wrapper = await mountTemplate(MdListItem, template)
1515

1616
expect(wrapper.hasClass('md-theme-alt')).toBe(true)
1717
})

src/components/MdList/MdListItem/MdListItem.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import MdRouterLinkProps from 'core/MdRouterLinkProps'
23
import MdListItemButton from './MdListItemButton'
34
import MdListItemLink from './MdListItemLink'
45
import MdListItemRouter from './MdListItemRouter'
@@ -15,10 +16,9 @@
1516
1617
if (parent && parent.$router && props.to) {
1718
listComponent = MdListItemRouter
18-
listComponent.props = {
19-
target: String,
20-
...parent.$options.components['router-link'].options.props
21-
}
19+
listComponent.props = MdRouterLinkProps(parent, {
20+
target: String
21+
})
2222
delete listComponent.props.href
2323
} else if (props.href) {
2424
listComponent = MdListItemLink

src/components/MdList/MdListItem/MdListItemContent.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
</template>
66

77
<script>
8+
import MdRipple from 'components/MdRipple/MdRipple.vue'
9+
810
export default {
911
name: 'MdListItemContent',
12+
components: {
13+
MdRipple
14+
},
1015
props: {
1116
mdDisabled: Boolean
1217
}

0 commit comments

Comments
 (0)