vue-web-component-wrapper icon indicating copy to clipboard operation
vue-web-component-wrapper copied to clipboard

`cssFrameworkStyles` are outputted lower in the shadowDOM tree than component styles

Open MarcHartwig13 opened this issue 2 months ago • 4 comments

When using the shadowDOM and cssFrameworkStyles the <style> tag for the cssFrameworkStyles is added to the DOM tree first. Then the styles from the component is added to the DOM second but right above the cssFrameworkStyles higher in the DOM.

This causes the cssFrameworkStyles to potentially override the component styles. Because cssFrameworkStyles should be more global styles I believe it should be the other way around and component styles should be further down the DOM so they override cssFrameworkStyles

Here is a recreation: https://stackblitz.com/edit/vitejs-vite-gakyc1kn?file=src%2Fmain.ts In this example I would expect the "HELLO WORLD" H1 tag to be blue and not red

And I believe this is where the change would need to be made: https://github.com/EranGrin/vue-web-component-wrapper/blob/main/package/src/web-component-util.js#L92

MarcHartwig13 avatar Oct 23 '25 21:10 MarcHartwig13

Hi there, You are more than welcome to open a PR; it seems like a valid issue. I should have time next week to review and work on this project.

EranGrin avatar Oct 24 '25 08:10 EranGrin

Hi, yup I'll work on getting a PR up for the fix, hopefully by this weekend

MarcHartwig13 avatar Oct 24 '25 16:10 MarcHartwig13

@EranGrin here is a PR to resolve the styling issue: https://github.com/EranGrin/vue-web-component-wrapper/pulls

but I did notice another issue, the styles are outputted twice. I go into more detail in the PR description

MarcHartwig13 avatar Nov 13 '25 20:11 MarcHartwig13

I'm quite busy with other projects currently; I hope I can find time for this project in the coming days.

EranGrin avatar Nov 16 '25 15:11 EranGrin