File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131 < description
3232 > A basic example of using TanStack Devtools with React.</ description
3333 >
34+
35+ <!--
36+ These styles exist only to verify that the Devtools UI
37+ does NOT inherit global styles. Because the devtools are
38+ rendered inside a Shadow Root, the rules below should have
39+ no visible effect.
40+ -->
41+ < style type ="text/css ">
42+ [data-testid = "tanstack_devtools" ] * {
43+ color : red !important ;
44+ }
45+ </ style >
3446 </ head >
3547 < body >
3648 < noscript > You need to enable JavaScript to run this app.</ noscript >
Original file line number Diff line number Diff line change @@ -188,9 +188,30 @@ export default function DevTools() {
188188 } )
189189 const { theme } = useTheme ( )
190190
191+ const [ gooberCss , setGooberCss ] = createSignal ( "" ) ;
192+ createEffect ( ( ) => {
193+ // Setup mutation observer for goober styles with id `_goober
194+ const gooberStyles = document . querySelector ( '#_goober' )
195+ if ( gooberStyles ) {
196+ setGooberCss ( gooberStyles . textContent )
197+ const observer = new MutationObserver ( ( ) => {
198+ setGooberCss ( gooberStyles . textContent )
199+ } )
200+ observer . observe ( gooberStyles , {
201+ childList : true , // observe direct children
202+ subtree : true , // and lower descendants too
203+ characterDataOldValue : true , // pass old data to callback
204+ } )
205+ onCleanup ( ( ) => {
206+ observer . disconnect ( )
207+ } )
208+ }
209+ } )
210+
191211 return (
192212 < ThemeContextProvider theme = { theme ( ) } >
193- < Portal mount = { ( pip ( ) . pipWindow ?? window ) . document . body } >
213+ < Portal mount = { ( pip ( ) . pipWindow ?? window ) . document . body } useShadow >
214+ < style > { gooberCss ( ) } </ style >
194215 < div ref = { setRootEl } data-testid = { TANSTACK_DEVTOOLS } >
195216 < Show
196217 when = {
Original file line number Diff line number Diff line change @@ -157,15 +157,10 @@ export const TanStackDevtools = ({
157157 } ,
158158 render : ( e , theme ) => {
159159 const id = e . getAttribute ( 'id' ) !
160- const target = e . ownerDocument . getElementById ( id )
161-
162- if ( target ) {
163- setPluginContainers ( ( prev ) => ( {
164- ...prev ,
165- [ id ] : e ,
166- } ) )
167- }
168-
160+ setPluginContainers ( ( prev ) => ( {
161+ ...prev ,
162+ [ id ] : e ,
163+ } ) )
169164 convertRender ( plugin . render , setPluginComponents , e , theme )
170165 } ,
171166 }
You can’t perform that action at this time.
0 commit comments