[wp-trac] [WordPress Trac] #48601: Twenty Twenty: document.body is null

WordPress Trac noreply at wordpress.org
Tue Nov 19 08:34:04 UTC 2019


#48601: Twenty Twenty: document.body is null
---------------------------+---------------------
 Reporter:  quicoto        |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  5.3.1
Component:  Bundled Theme  |     Version:  5.3
 Severity:  normal         |  Resolution:
 Keywords:  needs-patch    |     Focuses:
---------------------------+---------------------

Comment (by acosmin):

 @poena `document.body` will always be `null` if the script is loaded in
 the head section and it's not targeted when the dom is ready.

 The fact that the file is loaded asynchronously doesn't help with testing,
 depending on how fast it loads, it might return the `body` or `null` :)

 To easy test this we need to remove the `async` attribute. Comment out
 this line:
 https://github.com/WordPress/twentytwenty/blob/master/functions.php#L209

 Now open the page in Chrome > Inspect and click on `Toggle device toolbar`
 ctrl+shift+m on windows. Resize that frame and refresh the page. Result:
 `index.js?ver=1.0:83 Uncaught TypeError: Cannot read property 'classList'
 of null`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48601#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list