Skip to content

Commit 5e04331

Browse files
markbroucheddyerburgh
authored andcommitted
fix: polyfill Element.matches for IE < 11 (#1230)
fixes #1223
1 parent 23e496b commit 5e04331

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: packages/test-utils/src/mount.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { throwIfInstancesThrew, addGlobalErrorHandler } from './error'
55
import { mergeOptions } from 'shared/merge-options'
66
import config from './config'
77
import warnIfNoWindow from './warn-if-no-window'
8+
import polyfill from './polyfill'
89
import createWrapper from './create-wrapper'
910
import createLocalVue from './create-local-vue'
1011
import { validateOptions } from 'shared/validate-options'
@@ -15,6 +16,8 @@ Vue.config.devtools = false
1516
export default function mount(component, options = {}) {
1617
warnIfNoWindow()
1718

19+
polyfill()
20+
1821
addGlobalErrorHandler(Vue)
1922

2023
const _Vue = createLocalVue(options.localVue)

Diff for: packages/test-utils/src/polyfill.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default function polyfill() {
2+
// Polyfill `Element.matches()` for IE and older versions of Chrome:
3+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
4+
if (!Element.prototype.matches) {
5+
Element.prototype.matches =
6+
Element.prototype.msMatchesSelector ||
7+
Element.prototype.webkitMatchesSelector
8+
}
9+
}

0 commit comments

Comments
 (0)