diff --git a/packages/test-utils/src/mount.js b/packages/test-utils/src/mount.js index dee57d1c2..c6dab106d 100644 --- a/packages/test-utils/src/mount.js +++ b/packages/test-utils/src/mount.js @@ -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' @@ -15,6 +16,8 @@ Vue.config.devtools = false export default function mount(component, options = {}) { warnIfNoWindow() + polyfill() + addGlobalErrorHandler(Vue) const _Vue = createLocalVue(options.localVue) diff --git a/packages/test-utils/src/polyfill.js b/packages/test-utils/src/polyfill.js new file mode 100644 index 000000000..46020a47c --- /dev/null +++ b/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 + } +}