Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: allow custom <transition> stubs #2185

Merged
merged 1 commit into from
Sep 19, 2023
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
12 changes: 7 additions & 5 deletions src/vnodeTransformers/stubComponentsTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ const createDefaultStub = (
if (kebabTag in stubs && stubs[kebabTag] === false) return type
if (pascalTag in stubs && stubs[pascalTag] === false) return type

return createStub({
name: kebabTag,
type,
renderStubDefaultSlot: true
})
if (stubs[kebabTag] === true || stubs[pascalTag] === true) {
return createStub({
name: kebabTag,
type,
renderStubDefaultSlot: true
})
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions tests/mountingOptions/global.stubs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,24 @@ describe('mounting options: stubs', () => {
'</transition-stub>'
)
})

it('custom transition stub', () => {
const Comp = {
template: `<transition><div id="content-custom-stub" /></transition>`
}
config.global.stubs = {
transition: {
template: '<div class="custom-transition-stub"><slot /></div>'
}
}
const wrapper = mount(Comp)

expect(wrapper.html()).toBe(
'<div class="custom-transition-stub">\n' +
' <div id="content-custom-stub"></div>\n' +
'</div>'
)
})
})

describe('transition-group', () => {
Expand Down