@@ -285,6 +285,46 @@ describe('web components', () => {
285285 assert . equal ( getShadowHTML ( ) , '<p>Active theme: sunny</p>' ) ;
286286 } ) ;
287287
288+ it . only ( 'passes context over light DOM custom element boundaries' , async ( ) => {
289+ const Theme = createContext ( 'light' ) ;
290+
291+ function DisplayTheme ( ) {
292+ const theme = useContext ( Theme ) ;
293+ return < p > Active theme: { theme } </ p > ;
294+ }
295+
296+ function Parent ( { children, theme = 'dark' } ) {
297+ return (
298+ < Theme . Provider value = { theme } >
299+ < div class = "children" > { children } </ div >
300+ </ Theme . Provider >
301+ ) ;
302+ }
303+
304+ registerElement ( Parent , 'x-light-dom-parent' , [ 'theme' ] ) ;
305+ registerElement ( DisplayTheme , 'x-light-dom-child' , [ ] ) ;
306+
307+ const el = document . createElement ( 'x-light-dom-parent' ) ;
308+
309+ const noSlot = document . createElement ( 'x-light-dom-child' ) ;
310+ el . appendChild ( noSlot ) ;
311+
312+ root . appendChild ( el ) ;
313+ assert . equal (
314+ root . innerHTML ,
315+ '<x-light-dom-parent><div class="children"><x-light-dom-child><p>Active theme: dark</p></x-light-dom-child></div></x-light-dom-parent>'
316+ ) ;
317+
318+ // Trigger context update
319+ act ( ( ) => {
320+ el . setAttribute ( 'theme' , 'sunny' ) ;
321+ } ) ;
322+ assert . equal (
323+ root . innerHTML ,
324+ '<x-light-dom-parent><div class="children"><x-light-dom-child><p>Active theme: sunny</p></x-light-dom-child></div></x-light-dom-parent>'
325+ ) ;
326+ } ) ;
327+
288328 it ( 'renders element in shadow dom open mode' , async ( ) => {
289329 function ShadowDomOpen ( ) {
290330 return < div className = "shadow-child" > Shadow DOM Open</ div > ;
0 commit comments