Opened 18 months ago
Last modified 11 months ago
#58145 new defect (bug)
JS error: Uncaught ReferenceError: Element is not defined
Reported by: | 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 (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
window
variable.The fix would seem to be just to bail early if
window
is aWebWorker
object, similar to the existing 'Running in browser' check.