Opened 3 years ago
Last modified 2 years ago
#58145 new defect (bug)
JS error: Uncaught ReferenceError: Element is not defined
| Reported by: |
|
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 (2)
Note: See
TracTickets for help on using
tickets.
I'm also getting this.
In my case it's caused by a WebWorker within Yoast, which overwrites the
windowvariable.The fix would seem to be just to bail early if
windowis aWebWorkerobject, similar to the existing 'Running in browser' check.