vue-server-renderer: directive not applied to imported component
See original GitHub issueWhat problem does this feature solve?
Currently, SSR directives are not applied to used (sub-)components but only to HTML-tags and elements.
Reproduction
// Step 1: Create a Vue instance
const Vue = require("vue");
const Test = {
template: `<div>This should be red</div>`
}
const app = new Vue({
template: `
<div>
<Test v-make-red/>
<div v-make-red>This is red</div>
</div>
`,
components: {
Test
}
});
const makeRed = (node, dir) => {
const style = node.data.style || (node.data.style = {});
if (Array.isArray(style)) {
style.push({ backgroundColor: "red" });
} else {
style.backgroundColor = "red";
}
};
// Step 2: Create a renderer
const renderer = require("vue-server-renderer").createRenderer({
directives: {
makeRed
}
});
// Step 3: Render the Vue instance to HTML
renderer.renderToString(app, (err, html) => {
if (err) throw err;
console.log(html);
// <div data-server-rendered="true"><div>This should be red</div> <div style="background-color:red;">This is red</div></div>
// But should include red background-color style for the first div as well
});
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:5
Top Results From Across the Web
I have problem with new v-directive in nuxt3 project
i correctly implemented the primevue free component but when i try to use primeblock components ... Single component works, directive no
Read more >Server-Side Rendering (SSR) - Vue.js
The keyword here is static: SSG can only be applied to pages consuming static data, i.e. data that is known at build time...
Read more >vuejs custom directive does not seem to register
In the component where you want to use it, you would import autosize from "components/directives/autosize.js" and then you would have directives ...
Read more >vue-server-renderer | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >v-font - Nuxt Speedkit
The directive v-font is used to integrate the fonts defined in the module ... Read more: vue-server-renderer: directive not applied to imported component...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

hey guys. i use vue on a daily basis and i would like to contribute. I see here this is a contribution welcome label. can someone help me so i can start to fix this if possible?
(i already forked installed and can run test and build.)
+1 Still not working, nuxt@2.14.6 vue@2.6.12 vue-server-renderer@2.6.12