Skip to content

Commit

Permalink
feat(interpolation): enable passage of local components to tag prop
Browse files Browse the repository at this point in the history
  • Loading branch information
vhoyer committed Jul 29, 2020
1 parent 6304c34 commit 64d5e1e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
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

0 comments on commit 64d5e1e

Please sign in to comment.