Please test Tracy 2.13 RC – Tracy in its own Shadow DOM
- David Grudl
- founder | 8330
Hi,
I'd like to ask you to test Tracy 2.13.0-RC1. The main change is invisible at first sight: the Bar, BlueScreen and dumps now render into their own Shadow DOM, so the styles of your page and the styles of Tracy finally leave each other alone.
composer require tracy/tracy:^2.13.0-RC1
This is something I've been after ever since the Tracy Bar was born. The Bar
lives inside someone else's page, and that page does whatever it likes with it:
Bootstrap or Tailwind restyle it, and the other way round, Tracy's CSS sometimes
bent the page's tables. Over the years there were many attempts to deal with it,
but every one of them was some form of out-specifying the page: everything
hidden behind the #tracy-debug prefix, resetting inherited
properties, selectors like tracy-div:not(a b) whose only purpose
was to add specificity. There was no general solution, there was always a page
that won. Now and then a CSS property appeared that looked promising, but it
never got me there, because it simply wasn't meant for this. And CSS planned
various forms of scoping that never came to be.
Then, more or less by accident, I found out it could be done with Shadow DOM. Which turned out to be a brutally hard nut to crack, because everything has to move in there: styles, scripts, events, dragging panels, BlueScreen and dumps. I wasn't sure about it, so it's been sitting in the repository for a couple of years. Now it's time to test it and let it out.
How to test
Just install it and work as usual for a while: click through the panels in the Bar (especially those from other packages and your own), throw an exception and look at the BlueScreen, dump something. The ideal outcome is that you notice nothing. If nobody finds anything, great, I'll release the stable version.
What may affect your code
- Styles and scripts of the page no longer reach inside Tracy. Code that
targeted
#tracy-debug,#tracy-bs,<tracy-div>or the inside of a dump (e.g.document.querySelector('#tracy-debug')) finds nothing now. - A custom panel that relied on the page's styles has to ship its own CSS in
its markup. The
#tracy-debugwrapper is kept inside the Shadow DOM, so the selectors in existing panel CSS keep working. - The
ext-tokenizerextension is now required, and the Nette integration needsnette/diandnette/mail3.1 or newer.
Other new features
- The Bar lives in the top layer (Popover API), so it stays above the page's overlays and sticky headers whatever their z-index.
- Tracy works on pages with a strict CSP and Trusted Types
(
require-trusted-types-for 'script') through a policy namedtracy. Styles no longer need'unsafe-inline'instyle-src. Thanks to adrianbj for the Trusted Types support (nette/tracy#616). Debugger::$dumpTheme = 'auto'switches dumps between light and dark according to the system setting.- Toggles in dumps and panels can be operated with the keyboard (Tab, Enter, Space), and dragging the Bar and its panels works reliably on touch screens.
If something breaks or a panel looks different than before, please let me know. And feel free to say that everything works, too, that's just as useful to me. Thanks!