Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

⚡ improvement(interpolation): enable passage of local components to tag prop #928

Merged
merged 1 commit into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/interpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
functional: true,
props: {
tag: {
type: [String, Boolean],
type: [String, Boolean, Object],
default: 'span'
},
path: {
Expand Down
37 changes: 37 additions & 0 deletions test/unit/interpolation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,43 @@ describe('component interpolation', () => {
}).then(done)
})

it('of type object (Component) should be correctly applied', done => {
const MockElement = {
render(h) {
return h('strong', Object.values(this.$slots));
},
}
const el = document.createElement('div')
const vm = new Vue({
i18n,
render (h) {
return h('i18n', { props: { path: 'text', tag: MockElement } }, [this._v('1')])
}
}).$mount(el)
Vue.nextTick().then(() => {
assert.strictEqual(vm.$el.outerHTML, '<strong>one: 1</strong>')
}).then(done).catch(done)
})

it('of type object (Functional Component) should be correctly applied', done => {
const MockElement = {
functional: true,
render(h, { data, children }) {
return h('em', data, children);
},
}
const el = document.createElement('div')
const vm = new Vue({
i18n,
render (h) {
return h('i18n', { props: { path: 'text', tag: MockElement } }, [this._v('1')])
}
}).$mount(el)
Vue.nextTick().then(() => {
assert.strictEqual(vm.$el.outerHTML, '<em>one: 1</em>')
}).then(done).catch(done)
})

it('of type string should be correctly applied', done => {
const el = document.createElement('div')
const vm = new Vue({
Expand Down