File tree Expand file tree Collapse file tree 3 files changed +38
-10
lines changed Expand file tree Collapse file tree 3 files changed +38
-10
lines changed Original file line number Diff line number Diff line change 31
31
< description
32
32
> A basic example of using TanStack Devtools with React.</ description
33
33
>
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 >
34
46
</ head >
35
47
< body >
36
48
< 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() {
188
188
} )
189
189
const { theme } = useTheme ( )
190
190
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
+
191
211
return (
192
212
< ThemeContextProvider theme = { theme ( ) } >
193
- < Portal mount = { ( pip ( ) . pipWindow ?? window ) . document . body } >
213
+ < Portal mount = { ( pip ( ) . pipWindow ?? window ) . document . body } useShadow >
214
+ < style > { gooberCss ( ) } </ style >
194
215
< div ref = { setRootEl } data-testid = { TANSTACK_DEVTOOLS } >
195
216
< Show
196
217
when = {
Original file line number Diff line number Diff line change @@ -157,15 +157,10 @@ export const TanStackDevtools = ({
157
157
} ,
158
158
render : ( e , theme ) => {
159
159
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
+ } ) )
169
164
convertRender ( plugin . render , setPluginComponents , e , theme )
170
165
} ,
171
166
}
You can’t perform that action at this time.
0 commit comments