Make WordPress Core

Opened 6 weeks ago

Last modified 6 weeks ago

#58145 new defect (bug)

JS error: Uncaught ReferenceError: Element is not defined

Reported by: jankyz's profile jankyz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.2
Component: Editor Keywords: needs-patch
Focuses: javascript Cc:

Description

I've got a console error on editor level

uncaught ReferenceError: Element is not defined

file: wp-polyfill-inert.js
line:30

(function () {
    // Return early if we're not running inside of the browser.
    if (typeof window === 'undefined') {
      return;
    }

    // Convenience function for converting NodeLists.
    /** @type {typeof Array.prototype.slice} */
    var slice = Array.prototype.slice;

    /**
     * IE has a non-standard name for "matches".
     * @type {typeof Element.prototype.matches}
     */
    var matches = Element.prototype.matches || Element.prototype.msMatchesSelector;

suggestion

(function () {
    // Return early if we're not running inside of the browser.
    if (typeof window === 'undefined' || window?.Element) {
      return;
    }

    // Convenience function for converting NodeLists.
    /** @type {typeof Array.prototype.slice} */
    var slice = Array.prototype.slice;

    /**
     * IE has a non-standard name for "matches".
     * @type {typeof Element.prototype.matches}
     */
    var matches = Element.prototype.matches || Element.prototype.msMatchesSelector;

Change History (1)

#1 @jankyz
6 weeks ago

  • Keywords needs-patch added
  • Summary changed from JS error: caught ReferenceError: Element is not defined to JS error: Uncaught ReferenceError: Element is not defined
Note: See TracTickets for help on using tickets.