Skip to content

Commit

Permalink
BlueScreen: is wrapped in <tracy-div> and uses CSS reset instead of d…
Browse files Browse the repository at this point in the history
…isabling stylesheets [Closes nette#533]
  • Loading branch information
dg authored and forrest79 committed Apr 1, 2022
1 parent 0cd7933 commit 8c22ebc
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/Tracy/BlueScreen/BlueScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ private function renderTemplate(\Throwable $exception, string $template, $toScre
$dump = $this->getDumper();

$css = array_map('file_get_contents', array_merge([
__DIR__ . '/../assets/reset.css',
__DIR__ . '/assets/bluescreen.css',
__DIR__ . '/../assets/toggle.css',
__DIR__ . '/../assets/table-sort.css',
Expand Down
17 changes: 0 additions & 17 deletions src/Tracy/BlueScreen/assets/bluescreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,11 @@ class BlueScreen
{
static init(ajax) {
let blueScreen = document.getElementById('tracy-bs');
let styles = [];

for (let i = 0; i < document.styleSheets.length; i++) {
let style = document.styleSheets[i];
if (!style.ownerNode.classList.contains('tracy-debug')) {
style.oldDisabled = style.disabled;
style.disabled = true;
styles.push(style);
}
}

if (navigator.platform.indexOf('Mac') > -1) {
blueScreen.classList.add('tracy-mac');
}

document.getElementById('tracy-bs-toggle').addEventListener('tracy-toggle', function() {
let collapsed = this.classList.contains('tracy-collapsed');
for (let i = 0; i < styles.length; i++) {
styles[i].disabled = collapsed ? styles[i].oldDisabled : true;
}
});

if (!ajax) {
document.body.appendChild(blueScreen);
let id = location.href + document.querySelector('.tracy-section--error').textContent;
Expand Down
4 changes: 2 additions & 2 deletions src/Tracy/BlueScreen/assets/content.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Tracy;
* @var ?array $obStatus
*/
?>
<div id="tracy-bs" itemscope>
<tracy-div id="tracy-bs" itemscope>
<a id="tracy-bs-toggle" href="#" class="tracy-toggle"></a>
<div class="tracy-bs-main">
<?php $ex = $exception; $exceptions = []; ?>
Expand Down Expand Up @@ -68,4 +68,4 @@ namespace Tracy;
</footer>
</div>
<meta itemprop=tracy-snapshot content=<?= Dumper::formatSnapshotAttribute($snapshot) ?>>
</div>
</tracy-div>
2 changes: 1 addition & 1 deletion src/Tracy/BlueScreen/assets/page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Tracy;
$code = $exception->getCode() ? ' #' . $exception->getCode() : '';
$nonceAttr = $nonce ? ' nonce="' . Helpers::escapeHtml($nonce) . '"' : '';
$chain = Helpers::getExceptionChain($exception);
?><!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table>
?><!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table></p>
<html>
<head>
<meta charset="utf-8">
Expand Down
6 changes: 3 additions & 3 deletions tests/Tracy/expected/Debugger.E_ERROR.html.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table>
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table></p>
<html>
<head>
<meta charset="utf-8">
Expand All @@ -13,7 +13,7 @@


<body>
<div id="tracy-bs" itemscope>
<tracy-div id="tracy-bs" itemscope>
<a id="tracy-bs-toggle" href="#" class="tracy-toggle"></a>
<div class="tracy-bs-main">
<section class="tracy-section tracy-section--error">
Expand Down Expand Up @@ -259,7 +259,7 @@
</footer>
</div>
<meta itemprop=tracy-snapshot content=%a%>
</div>
</tracy-div>

<script>%A%</script>
</body>
Expand Down
6 changes: 3 additions & 3 deletions tests/Tracy/expected/Debugger.error-in-eval.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table>
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table></p>
<html>
<head>
<meta charset="utf-8">
Expand All @@ -13,7 +13,7 @@


<body>
<div id="tracy-bs" itemscope>
<tracy-div id="tracy-bs" itemscope>
<a id="tracy-bs-toggle" href="#" class="tracy-toggle"></a>
<div class="tracy-bs-main">
<section class="tracy-section tracy-section--error">
Expand Down Expand Up @@ -204,7 +204,7 @@
</footer>
</div>
<meta itemprop=tracy-snapshot content=%a%>
</div>
</tracy-div>

<script>%A%</script>
</body>
Expand Down
6 changes: 3 additions & 3 deletions tests/Tracy/expected/Debugger.exception.html.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table>
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table></p>
<html>
<head>
<meta charset="utf-8">
Expand All @@ -13,7 +13,7 @@


<body>
<div id="tracy-bs" itemscope>
<tracy-div id="tracy-bs" itemscope>
<a id="tracy-bs-toggle" href="#" class="tracy-toggle"></a>
<div class="tracy-bs-main">
<section class="tracy-section tracy-section--error">
Expand Down Expand Up @@ -213,7 +213,7 @@
</footer>
</div>
<meta itemprop=tracy-snapshot content=%a%>
</div>
</tracy-div>

<script>%A%</script>
</body>
Expand Down
6 changes: 3 additions & 3 deletions tests/Tracy/expected/Debugger.strict.html.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table>
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template></title></table></p>
<html>
<head>
<meta charset="utf-8">
Expand All @@ -13,7 +13,7 @@


<body>
<div id="tracy-bs" itemscope>
<tracy-div id="tracy-bs" itemscope>
<a id="tracy-bs-toggle" href="#" class="tracy-toggle"></a>
<div class="tracy-bs-main">
<section class="tracy-section tracy-section--error">
Expand Down Expand Up @@ -207,7 +207,7 @@
</footer>
</div>
<meta itemprop=tracy-snapshot content=%a%>
</div>
</tracy-div>

<script>%A%</script>
</body>
Expand Down

0 comments on commit 8c22ebc

Please sign in to comment.