SOLVED: TypeError in bricks.min.js

Browser: Firefox 143, Chrome 141
OS: macOS
URL: -
Video: -

Website was just upgraded to 2.1 (using child theme) and now all frontend pages have the following error. This seems to break javascript page-wide, such as sliders.

Uncaught TypeError: can’t access property “classList”, document.body is null
https://www.example.com/wp-content/themes/bricks/assets/js/bricks.min.js?ver=1760038432:1

Which refers to this block:

if(document.body.classList.contains(“block-editor-page”)){…

Seems strange that document.body would be null. Maybe it needs to be deferred?

1 Like

Downgraded to 2.0.2 and the issue isn’t present with that version.

Hi @sthomas,

can you share a link to the website, where I can see the console error? Because I can’t replicate it locally on my end.

Thank you,
Matej

I have the same Error, but only inside the builder.
Everything renders fine inside the builder,except for one Custom Element that is useing the bricksSwiper script, if that helps. (It used to work completly fine before).

<?php

if (!defined('ABSPATH')) exit;

class UF_Hero_Slider extends Userfreunde\Bricks\Element
{
  public $category     = self::DEFAULT_CATEGORY;
  public $name         = 'uf-hero-slider';
  public $icon         = 'ti-layout-slider-alt';
  public $tag          = 'div';
  public $scripts      = ['bricksSwiper'];

Also I get a lot of TypeErrors like below, all related to bricks.min.js:

Uncaught TypeError: can't access property "run", bricksFormFn is undefined
Uncaught TypeError: can't access property "run", bricksBackgroundVideoInitFn is undefined
Uncaught TypeError: can't access property "run", bricksBackgroundVideoInitFn is undefined
...

@Matej I can’t give you access to that perticular site today, since I want to launch it later and the domain will change, but I can look into it next week.

Had the same problem.
Replaced it with if(document.body && document.body.classList.contains(“block-editor-page”)) to prevent the error.
The if-clause fires too early. It is not waiting for the page to be loaded and ready, so document.body does not exist yet.

Hi @sthomas , @UserfreundSuat and @nickfuxteufelsweb.

We fixed this issue in Bricks 2.1.2 (Hotfix), now available as a one-click update in your WordPress Dashboard.

Please take a moment to read the changelog entries before updating:

You can also review the 2.1 and 2.1.1 changelogs to see all previous changes:

Let us know if you continue to experience any issues.

Best regards,
Matej

3 Likes