Make WordPress Core

Opened 2 years ago

Closed 21 months ago

#56185 closed defect (bug) (invalid)

Having an element with id="module" in the admin panel generates a regenerator-runtime.js error

Reported by: m1r0's profile m1r0 Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Administration Keywords: close
Focuses: javascript Cc:


I've noticed this minor bug while making a custom post type column named "module" but it could be reproduced by adding any HTML element with the id "module".

These are the steps to reproduce the issue:

  1. In the admin panel, create an element with the id="module".
    add_action( 'admin_footer', function() {
            echo '<div id="module"></div>';
    } );
  2. Refresh the admin panel and open the console in the browser.
  3. You should see a bunch of errors and the first one should be Cannot set properties of undefined (setting 'wrap').

After enabling SCRIPT_DEBUG, I've tracked down the error to regenerator-runtime.js.

regenerator-runtime.js?ver=0.13.9:49 Uncaught TypeError: Cannot set properties of undefined (setting 'wrap')
    at regenerator-runtime.js?ver=0.13.9:49:16
    at regenerator-runtime.js?ver=0.13.9:728:2

Cheers and thanks for the great work!

Change History (4)

#1 @TimothyBlynJacobs
2 years ago

  • Keywords close added

Hi @m1r0,

I don't think this is a bug in the regenerator runtime codebase itself. I think this is part of CommonJS which uses the module global to pass dependencies around.

Part of how browsers work is they globalize any HTML elements with an id.

This is then conflicting with the CommonJS code that is looking for a global named module.

My recommendation would be to prefix everything, that includes classes and ids.

Cc: @youknowriad who is the author of Regenerator Runtime.

#2 @m1r0
2 years ago

Thanks for the suggestion, @TimothyBlynJacobs!

Just to clarify and potentially help someone, I've come across this issue by creating a custom column named "module" which in turn created a table header with that ID. (<th scope="col" id="module" class="manage-column column-module">Module</th>)

#3 @desrosj
22 months ago

  • Milestone Awaiting Review deleted
  • Version trunk deleted

@TimothyBlynJacobs Regenerator runtime is a Facebook package we pull in from npm.

Closing this one out as there does not seem to be any action required.

#4 @desrosj
21 months ago

  • Resolution set to invalid
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.