Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WDT: Only load "Sfjs" if it is not present already#41168

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:4.4fromweaverryan:sf-debug-turbo
May 11, 2021

Conversation

@weaverryan
Copy link
Member

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
Ticketsnone
LicenseMIT
Doc PRnot needed

Hi!

Playing with Turbo, I noticed two small issues with the WDT:

  1. When you click a link (which Turbo loads via AJAX), the new toolbar would correctly load, but its "AJAX tab" would be missing/empty. At first, that seems.. at least... "correct enough". After all, wedid just load a new web debug toolbar. However, this can be avoided by simplynot redefining theSfjs variable: if it already exists, just use it. And this is the intention of that object, I believe: for it to be loadedonce, and then reused over and over again via itsloadToolbar() method.

  2. Additionally, I was experimenting with some crazy prefetch + Turbo functionality. It works, but caused one minor issue with the web debug toolbar. The flow is this:

A) A prefetch request is made to pre-cache a URL in Turbo.
B) When that links is actually clicked, the cached version from (A) is used as the "Preview". It's HTML callsSfjs.loadToolbar().
C) At the same moment as (B), another AJAX request is made to the same URL from (A) to get the full, fresh page (in case it's out of date).
D) When (C) finishes, it will have its ownSfjs.loadToolbar() call.

The problem is that the AJAX request for the first web debug toolbar (from B) sometimes finishesafter the AJAX call made by Turbo for (C). The result is that the first web debug toolbar tries to activate itself... but it's already gone from the page.

I realize this is a... kind of crazy scenario, but I think the fix is legit: if, for any reason, the web debug toolbar element is not on the page, we should not try to initialize it. It results in:

Screen Shot 2021-05-10 at 3 49 06 PM

To Test

JUST to be on the safe side, I prepared a symfony-demo app with Turbo installed, and using these changes. You can try it here -https://github.com/weaverryan/symfony-demo/tree/turbo - the README is updated to quickly get it running (no need to even run yarn, the JavaScript files are committed).

Thanks!

Plus, avoid loading the toolbar if it is no longer on the page
@fabpot
Copy link
Member

Thank you@weaverryan.

@fabpotfabpot merged commit89c1be8 intosymfony:4.4May 11, 2021
@weaverryanweaverryan deleted the sf-debug-turbo branchMay 11, 2021 12:51
This was referencedMay 12, 2021
nicolas-grekas added a commit that referenced this pull requestMay 21, 2021
…d also loading base_js Sfjs if needed (weaverryan)This PR was merged into the 4.4 branch.Discussion----------[WebProfilerBundle] Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#41305| License       | MIT| Doc PR        | Not neededThis bug was introduced in#41168.Best viewed with:https://github.com/symfony/symfony/pull/41346/files?w=1 - we could also remove the new indentation in `exception.js`.In that PR, we innocently don't reload `Sfjs` if it doesn't exist. However, on an error page, that template ALSO adds an `Sfjs`, and that `Sfjs` is *smaller* - containing only a subset of the `Sfjs` functions. This is tricky, but this PR fixes it.Here are the various situations:1) I hit an exception page. The `Sfjs` from `exception.js` is loaded first. This adds the smaller `Sfjs`. Then the `base_js.html.twig` version is hit. Because `Sfjs` is missing the `loadToolbar()` method, that code DOES run again to reinitialize it.2) I am on a normal page, then travel to an exception page with Turbo. In this case, the original `Sfjs` from `base_js.html.twig` was processed. Then, on the exception page, the `Sfjs` from `exception.js` is ignored, as is the 2nd execution of `base_js.html.twig`.Overall, the JS could use some work for supporting things like Turbo (e.g. `DOMContentLoaded` doesn't work with Turbo, so the exception page JS is broken). But I wanted to focus on fixing the bug in this PR.As a reminder,#41168 (avoiding overriding `Sfjs`) was done to help with the AJAX toolbar and Turbo - it's explained in point (1) on#41168.Cheers!Commits-------5fa42f1 Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@stofstofstof approved these changes

@chalasrchalasrchalasr approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

5 participants

@weaverryan@fabpot@stof@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp