#46474 closed defect (bug) (fixed)
Twenty Nineteen: function matches() does not exist
Reported by: | janpaulkleijn | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | 5.1 |
Component: | Bundled Theme | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
In the themefiles (in the /js dir) there is a file called 'touch-keyboard-navigation.js'. This file uses the function matches() on lines 167 and 172.
It appears there is an issue with the use of the function matches() in my browser (Mozilla Firefox 65.0.2 64bit). I get the notice in the console that the function matches() does not exist.
I solved this with the use of a polyfill that is published by Mozilla: https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
Steps to reproduce: Use the twentynineteen theme in the aforementioned Mozilla Firefox browser and click on the page (anywhere).
Attachments (2)
Change History (14)
#2
@
6 years ago
- Keywords needs-patch needs-testing added; has-patch removed
- Summary changed from function matches() does not exist in the Twenty Nineteen theme to Twenty Nineteen: Element.matches() does not exist
This is the polyfill you are referring too?
if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; }
#3
@
6 years ago
- Keywords has-patch added; needs-patch needs-testing removed
- Summary changed from Twenty Nineteen: Element.matches() does not exist to function matches() does not exist in the Twenty Nineteen theme
Forget the polyfill, I was wrong. I suppressed the issue by changing line 277 from:
... if ( event.target.matches('.main-navigation > div > ul > li a') ) { ...
to:
... if ( event.target != window.document && event.target.matches('.main-navigation > div > ul > li a') ) { ...
But perhaps you have a better solution?
#4
@
6 years ago
- Keywords needs-patch needs-testing added; has-patch removed
@janpaulkleijn, Firefox shows an error when we focus on current page menu item, Below your solution solve that issue for for me in Firefox.
if ( event.target != window.document && event.target.matches('.main-navigation > div > ul > li a') ) {
#7
@
5 years ago
- Summary changed from function matches() does not exist in the Twenty Nineteen theme to Twenty Nineteen: function matches() does not exist
#8
@
22 months ago
- Milestone changed from Awaiting Review to 6.3
Both patches solve the JavaScript error for me, and the menus still work well.
Tested on windows 10:
Firefox; version 112.0.1
Chrome: Version 112.0.5615.121
Edge: Version 112.0.1722.48
Opera: version 97.0.4719.63
MacOS:
Firefox: version 112.0.1
Chrome: Version 112.0.5615.12
Safari 16.4
Android phone:
Firefox 112.0,
Chrome 112.0.5615.100,
Edge
Related: This issue, plus one other, is also reported at https://core.trac.wordpress.org/ticket/45903
Steps (2) to reproduce update: To reproduce the issue, use the twentynineteen theme in the aforementioned Mozilla Firefox browser, go to the homepage and switch to another tab and then back to the twentynineteen theme.
The error thrown by Mozilla firefox:
More specs about the error thrown by Mozilla firefox:
The line of code involved (line 277):