Skip to content

Commit

Permalink
fix(content): merge class and style attribute (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
NozomuIkuta committed Oct 21, 2021
1 parent d2fa9df commit d905ffe
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/content/templates/nuxt-content.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import info from 'property-information'

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

const rxOn = /^@|^v-on:/
const rxBind = /^:|^v-bind:/
Expand Down
12 changes: 11 additions & 1 deletion packages/content/test/component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ describe('component', () => {

expect(html).toMatch(
// eslint-disable-next-line prefer-regex-literals
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>/)
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>/)
)
})

test('has rendered a Vue.js functional component', async () => {
page = await browser.page(url('/vue-component'))
const html = await page.getHtml()

expect(html).toMatch(
// eslint-disable-next-line prefer-regex-literals
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>/)
)
})

Expand Down
2 changes: 1 addition & 1 deletion packages/content/test/fixture/components/AppLayout.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div class="app-layout" style="background-color: blue;">
<header><slot name="header" /></header>
<main><slot>Default content</slot></main>
<footer><slot name="footer" /></footer>
Expand Down
14 changes: 14 additions & 0 deletions packages/content/test/fixture/components/FnComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
export default {
functional: true,
render (h, { data }) {
return h('AppLayout', {
...data,
scopedSlots: {
header: () => h('Header content'),
footer: () => h('Footer content')
}
}, [])
}
}
</script>
4 changes: 2 additions & 2 deletions packages/content/test/fixture/content/vue-component.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<app-layout>
<app-layout class="dark" style="color: red;">
<template #header>Header content</template>
Main content
<template #footer>Footer content</template>
</app-layout>
</app-layout>
5 changes: 5 additions & 0 deletions packages/content/test/fixture/content/vue-fn-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<app-layout class="dark" style="color: red;">
<template #header>Header content</template>
Main content
<template #footer>Footer content</template>
</app-layout>

0 comments on commit d905ffe

Please sign in to comment.