Addon-docs: Add support for Vue 3 #13809
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: Follow up to #13775
What I did
I added initial support for Vue 3 in
@storybook/addon-docs
. This was mostly a copy-paste of thevue
implementation, but theprepareForInline
became very streamlined since Vue 3 allows you to render a vnode directly into the DOM.Notably missing: The
sourceDecorator
from Vue 2 won't work because vnodes no longer contain all the information to build up the templates. I explored callingrender(vnode, document.createElement('div'))
before looking at the props and it helped a bit, but I think the true way to build this would be a custom renderer, similar to how they do SSR and their test utils. However, that is way out of my depth.I also needed to fix the types in the html framework for some reason.
How to test
I tested this in the vue 3 example storybook and it seems to be working.
If your answer is yes to any of these, please make sure to include it in your PR.