-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
using var-dumper as standalone, expand or collapse not working #50487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It is, since that change expected the generated markup to be embedded in |
Any way to remove this expectation? |
I don’t know if |
This should do the trick... diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
index 345a89cf72..8a2570b2c4 100644
--- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
@@ -163,9 +163,7 @@ class HtmlDumper extends CliDumper
<script>
Sfdump = window.Sfdump || (function (doc) {
-if (doc.body instanceof HTMLElement) {
- doc.body.classList.add('sf-js-enabled');
-}
+doc.documentElement.classList.add('sf-js-enabled');
var rxEsc = /([.*+?^${}()|\[\]\/\\])/g,
idRx = /\bsf-dump-\d+-ref[012]\w+\b/, |
based on previous comments, i came up with a temporary workaround. function dump(...$vars)
{
static $first = true;
if ($first) {
$first = false;
echo '<html><body>';
}
foreach ($vars as $var) {
\Symfony\Component\VarDumper\VarDumper::dump($var);
}
}
function dd(...$vars)
{
dump(...$vars);
exit(1);
} |
@anovsiradj doesn’t #50487 (comment) work for you? |
i just try it, yes it is work. |
… JS flag Using `document.documentElement` allows to use the dumper outside of a `<html><body>...</body></html>` scenario. Fixes: symfony#50487
Using `document.documentElement` allows to use the dumper outside of a `<html><body>...</body></html>` scenario. Fixes: symfony#50487
Using `document.documentElement` allows to use the dumper outside of a `<html><body>...</body></html>` scenario. Fixes: symfony#50487
…g (ohader) This PR was merged into the 6.3 branch. Discussion ---------- [VarDumper] Use documentElement instead of body for JS flag | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #50487 | License | MIT | Doc PR | --- Fixes: #50487 Using `document.documentElement` allows to use the dumper outside of a `<html><body>...</body></html>` scenario. Commits ------- 91e6e57 [VarDumper] Use documentElement instead of body for JS flag
I am not sure if this change brings back the JavaScript issue mentioned in #39394. I noticed that the HTML was rendered with the CSS style
Since the issue mentioned was in v5.2, and the code changes in #39525 are very different in v6.3, would you mind taking a look to see if this is related? Thank you so much. |
@ohader I noticed that the expand/collapse arrow button is missing too. |
That's strange. I was not able to reproduce that (using latest commit 9767270 of the 6.4 branch). ![]() Can you share the created HTML markup and the PHP source that was used to create the output? Maybe referenced in a separate Gist to avoid blowing up this issue? Thx in advance! |
I added dd() in an api call, and response like https://gist.github.com/cryank/b3ebe7d6af2406edd77344e49fe8e9f1 when the ajax call is 500, I checked if the response data includes However when I created a static page to dd the same array, everything just looks fine |
I'm glad to hear, that it works on static pages (phew 😅). Thus, this seems to be an edge case with those modals, and how content is applied in your custom JavaScript. |
Symfony version(s) affected
n/a
Description
after upgrading var-dumper to 6.3, when using
dump()
ordd()
, expand or collapse for object/array/string suddenly not working.Recording.2023-05-31.074847.mp4
How to reproduce
composer init
then installsymfony/var-dumper
v6.3index.php
in browsercomposer.json.txt
index.php.txt
Possible Solution
No response
Additional Context
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
The text was updated successfully, but these errors were encountered: