File tree 1 file changed +24
-0
lines changed
packages/runtime-dom/__tests__ 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -791,6 +791,30 @@ describe('defineCustomElement', () => {
791
791
assertStyles ( el , [ `div { color: blue; }` , `div { color: red; }` ] )
792
792
} )
793
793
794
+ test ( "child components should not inject styles to root element's shadow root w/ shadowRoot false" , async ( ) => {
795
+ const Bar = defineComponent ( {
796
+ styles : [ `div { color: green; }` ] ,
797
+ render ( ) {
798
+ return 'bar'
799
+ } ,
800
+ } )
801
+ const Baz = ( ) => h ( Bar )
802
+ const Foo = defineCustomElement (
803
+ {
804
+ render ( ) {
805
+ return [ h ( Baz ) ]
806
+ } ,
807
+ } ,
808
+ { shadowRoot : false } ,
809
+ )
810
+
811
+ customElements . define ( 'my-foo-with-shadowroot-false' , Foo )
812
+ container . innerHTML = `<my-foo-with-shadowroot-false></my-foo-with-shadowroot-false>`
813
+ const el = container . childNodes [ 0 ] as VueElement
814
+ const style = el . shadowRoot ?. querySelector ( 'style' )
815
+ expect ( style ) . toBeUndefined ( )
816
+ } )
817
+
794
818
test ( 'with nonce' , ( ) => {
795
819
const Foo = defineCustomElement (
796
820
{
You can’t perform that action at this time.
0 commit comments