Skip to content
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

[Widgets editor] TypeError: Cannot read property 'body' of null at onLoad #34164

Closed
2 tasks done
adamziel opened this issue Aug 19, 2021 · 6 comments
Closed
2 tasks done
Labels
[Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended

Comments

@adamziel
Copy link
Contributor

adamziel commented Aug 19, 2021

Description

In some scenarios – and I am not sure which ones – the legacy widget preview results in an error TypeError: Cannot read property 'body' of null at onLoad. Stack trace points to the following line:

event.target.contentDocument.body.style.overflow =

The problem occurs both in customizer and on widgets.php

Step-by-step reproduction instructions

  1. Be a lucky owner of an affected site – I am not sure how to reproduce the pre-conditions, but there are no custom plugins or themes involved
  2. Go to customizer or the widgets editor
  3. Observe the error

Screenshots, screen recording, code snippet

No response

Environment info

No response

Pre-checks

  • I have searched the existing issues.
  • I have tested with all plugins deactivated except Gutenberg.
@adamziel adamziel added [Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets [Package] Edit Widgets /packages/edit-widgets labels Aug 19, 2021
@noisysocks noisysocks added this to the WordPress 5.8.1 milestone Aug 20, 2021
@adamziel
Copy link
Contributor Author

adamziel commented Aug 20, 2021

There are two possibilities here:

  1. event.target is somehow not an iframe
  2. event.target is an iframe, but contentDocument is null

According to the HTML Living Standard:

The content document of a browsing context container container is the result of the following algorithm:

* If container's nested browsing context is null, then return null.
* Let context be container's nested browsing context.
* Let document be context's active document.
* If document's origin and container's node document's origin are not same origin-domain, then return null.
* Return document.

My guess is that the nested browsing context is not null because it was just populated, which leaves us with just one possibility: <iframe src="" /> points to a different origin than the document's origin. If so, this problem should be fixed by switching to <iframe srcdoc="" /> populated via apiFetch(): #34184

@noisysocks
Copy link
Member

If so, this problem should be fixed by switching to <iframe srcdoc="" /> populated via apiFetch(): #34184

@adamziel @anton-vlasenko: Did we ever do this?

@noisysocks noisysocks added [Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request. Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended and removed [Package] Edit Widgets /packages/edit-widgets [Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request. labels Feb 21, 2022
@noisysocks
Copy link
Member

If so, this problem should be fixed by switching to <iframe srcdoc="" /> populated via apiFetch(): #34184

@adamziel @anton-vlasenko: Did we ever do this?

Looks like it's tracked in #33540..

@ndiego
Copy link
Member

ndiego commented Aug 2, 2022

@noisysocks and @adamziel this issue came up in our weekly Editor Bug Scrub and I just wanted to check in. Seems like work on the Legacy Widget block has stalled? Just curious if this is an issue we are actively planning to fix, or if it can be closed as a "[Status] Not Implemented".

@noisysocks
Copy link
Member

I don't believe anyone is working on this, no. If we're struggling to reproduce this and not hearing many reports from users then I'd be happy to close.

@ndiego
Copy link
Member

ndiego commented Aug 9, 2022

Thanks for the follow-up @noisysocks. We reviewed it again during this week's Editor Bug Scrub, and the consensus was to close this ticket.

@ndiego ndiego closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants