Subscribe on changes!

styles in a v-html htmlString are being applied to the whole document

avatar
Nov 14th 2023

Vue version

3.3.8

Link to minimal reproduction

https://play.vuetifyjs.com/#eNp9VE1v2zAM/SuELr0sdoZuwJC5xorsOGDA0J3qHmRbbYTKkiAxboMg/72UbKfxR3uy9MRHPj7Ruj8y76r01tqk3Qu2YRmKxiqOIi80QNauuLVxGTeV0cilFq6HIlhLrswTvMgadzcF+75eF+x8ThFDRmhXXhnc8Aply9E4Cj6CdcZ6OI0oMW2Jmhil1DXFxaiCAYpXpO1fKzT8jnWJCFkaw8cZbI7CY5YO8iOYXrT3icRaPPK9CpWOIP1tECyWNFbc1SMsomiMKrmDyqjYpHWy4e5A8mvungElKkFwkCf1E4RwlHaS/cIFSbbPzs6ViAqXllruhEYqpkzFURpNWGkQTVOweRKAfGvsAf7/+wN3BrZK2tJQV8HSQdiMtCwmymxqGaeEJNDXHkKeRf1Ld9ahvX3Tk1q20xztaoeNov6usrCgQfB4UCK3cOzM3zhR/zxlaQdDtvua3/WuJ0mSpbSnkpF7NXUnz1IqOZqTi1tfBcuN9kt35i2v6BcJvfTLaZLhauc+9gO+VcaL84TPw35VSlbPFDhMZ9JytRdwA49ceTGnRDXLfn/YznD40Q/0HtU9AcM7EWijhyIg3Tsy4rPTF3adXCc/WPh+S9bs4Q3XOUoH

Steps to reproduce

press open dialog, the "test" will change to red

What is expected?

htmlString style should not be applied outside the v-html div, only to the elements that are in the htmlString.

What is actually happening?

as you can see in the playground, the "test" changes to red color

System Info

Vuetify Version: 3.4.0
Vue Version: 3.3.8
Browsers: Edge 119.0.0.0
OS: Windows 10

Any additional comments?

No response

avatar
Nov 14th 2023

This is working as expected as styles are global. You can use <style scoped> in SFCs to apply scoped styles.

avatar
Nov 14th 2023

found a solution i use iframe :srcdoc="htmlString" instead of v-html if anyone encounters the same issue it might fix that also