Skip to content

Commit d905ffe

Browse files
authored
fix(content): merge class and style attribute (#905)
1 parent d2fa9df commit d905ffe

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

Diff for: packages/content/templates/nuxt-content.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import info from 'property-information'
22

3-
const rootKeys = ['class-name', 'class', 'style']
3+
const rootKeys = ['class-name', 'class', 'className', 'style']
44

55
const rxOn = /^@|^v-on:/
66
const rxBind = /^:|^v-bind:/

Diff for: packages/content/test/component.test.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,17 @@ describe('component', () => {
4343

4444
expect(html).toMatch(
4545
// eslint-disable-next-line prefer-regex-literals
46-
new RegExp(/<div>\s*<h1><\/h1>\s*<div class="nuxt-content">\s*<div>\s*<header>Header content<\/header>\s*<main>\s*Main content\s*<\/main>\s*<footer>Footer content<\/footer><\/div><\/div><\/div>/)
46+
new RegExp(/<div>\s*<h1><\/h1>\s*<div class="nuxt-content">\s*<div class="app-layout dark" style="background-color:blue;color:red;">\s*<header>Header content<\/header>\s*<main>\s*Main content\s*<\/main>\s*<footer>Footer content<\/footer><\/div><\/div><\/div>/)
47+
)
48+
})
49+
50+
test('has rendered a Vue.js functional component', async () => {
51+
page = await browser.page(url('/vue-component'))
52+
const html = await page.getHtml()
53+
54+
expect(html).toMatch(
55+
// eslint-disable-next-line prefer-regex-literals
56+
new RegExp(/<div>\s*<h1><\/h1>\s*<div class="nuxt-content">\s*<div class="app-layout dark" style="background-color:blue;color:red;">\s*<header>Header content<\/header>\s*<main>\s*Main content\s*<\/main>\s*<footer>Footer content<\/footer><\/div><\/div><\/div>/)
4757
)
4858
})
4959

Diff for: packages/content/test/fixture/components/AppLayout.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div>
2+
<div class="app-layout" style="background-color: blue;">
33
<header><slot name="header" /></header>
44
<main><slot>Default content</slot></main>
55
<footer><slot name="footer" /></footer>
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
export default {
3+
functional: true,
4+
render (h, { data }) {
5+
return h('AppLayout', {
6+
...data,
7+
scopedSlots: {
8+
header: () => h('Header content'),
9+
footer: () => h('Footer content')
10+
}
11+
}, [])
12+
}
13+
}
14+
</script>
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<app-layout>
1+
<app-layout class="dark" style="color: red;">
22
<template #header>Header content</template>
33
Main content
44
<template #footer>Footer content</template>
5-
</app-layout>
5+
</app-layout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<app-layout class="dark" style="color: red;">
2+
<template #header>Header content</template>
3+
Main content
4+
<template #footer>Footer content</template>
5+
</app-layout>

0 commit comments

Comments
 (0)