Skip to content

feat(shared): expose rawChildrenMap in context #5082

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jaulz
Copy link
Contributor

@jaulz jaulz commented Dec 9, 2021

This PR exposes the raw children map in the context so custom directives can do the same as v-html does:
https://github.com/vuejs/vue-next/blob/master/packages/compiler-ssr/src/transforms/ssrTransformElement.ts#L171

As a side effect it gets rid of this static (though weak) map:
https://github.com/vuejs/vue-next/blob/master/packages/compiler-ssr/src/transforms/ssrTransformElement.ts#L53-L56

@posva
Copy link
Member

posva commented Dec 9, 2021

What feature is this implementing? If there isn't any, do you have a real world scenario that requires this change?

@posva posva added need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. need more info Further information is requested labels Dec 9, 2021
@jaulz
Copy link
Contributor Author

jaulz commented Dec 9, 2021

@posva yep, like I mentioned this change will allow custom directives to do the same as v-html does. In my case I have a v-emojis directive that walks through it's children and replaces UTF-8 emojis with images (<img src="..." />). Since it is supposed to work in SSR context as well this is the only possible way that I found how it could possibly work. The v-html directive takes the expression and sets it in the rawChildrenMap (see https://github.com/vuejs/vue-next/blob/master/packages/compiler-ssr/src/transforms/ssrTransformElement.ts#L170-L171) but this map is not exposed anywhere so the v-html directive is the only directive that can take advantage of it.

Update: I forgot to say that this PR does not change any existing functionality and all tests are supposed to still pass (which they did in my local environment). This PR just exposes the map in the context so custom directives can make use of it.

@jaulz
Copy link
Contributor Author

jaulz commented Dec 10, 2021

The failing test does not fail in my local environment...

@jaulz
Copy link
Contributor Author

jaulz commented Jan 11, 2022

@posva any chance to have a look at it again after my explanation? thanks! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. need more info Further information is requested
Projects
Development

Successfully merging this pull request may close these issues.

2 participants