Skip to content

Commit

Permalink
fix: polyfill Element.matches for IE < 11 (#1230)
Browse files Browse the repository at this point in the history
fixes #1223
  • Loading branch information
markbrouch authored and eddyerburgh committed May 11, 2019
1 parent 23e496b commit 5e04331
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/test-utils/src/mount.js
Expand Up @@ -5,6 +5,7 @@ import { throwIfInstancesThrew, addGlobalErrorHandler } from './error'
import { mergeOptions } from 'shared/merge-options'
import config from './config'
import warnIfNoWindow from './warn-if-no-window'
import polyfill from './polyfill'
import createWrapper from './create-wrapper'
import createLocalVue from './create-local-vue'
import { validateOptions } from 'shared/validate-options'
Expand All @@ -15,6 +16,8 @@ Vue.config.devtools = false
export default function mount(component, options = {}) {
warnIfNoWindow()

polyfill()

addGlobalErrorHandler(Vue)

const _Vue = createLocalVue(options.localVue)
Expand Down
9 changes: 9 additions & 0 deletions packages/test-utils/src/polyfill.js
@@ -0,0 +1,9 @@
export default function polyfill() {
// Polyfill `Element.matches()` for IE and older versions of Chrome:
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector
}
}

0 comments on commit 5e04331

Please sign in to comment.