aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2019-03-16 16:10:23 +0200
committerXhmikosR <[email protected]>2019-03-18 01:11:05 +0200
commit08679ac0b5f34e1a1f1766be460e51bc1aa8d82a (patch)
tree2cef1cf8f17668c56b410c4c3e32a55bd4853af9 /js/tests/unit
parentf7c1b1e683976ee780faadddc4edc70b477aa01f (diff)
downloadbootstrap-08679ac0b5f34e1a1f1766be460e51bc1aa8d82a.tar.xz
bootstrap-08679ac0b5f34e1a1f1766be460e51bc1aa8d82a.zip
Add back support for IE 11
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/modal.js25
-rw-r--r--js/tests/unit/tests-polyfills.js28
2 files changed, 46 insertions, 7 deletions
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index 87d778b86..82b37f236 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -731,7 +731,14 @@ $(function () {
})
QUnit.test('should enforce focus', function (assert) {
- assert.expect(2)
+ var isIE11 = Boolean(window.MSInputMethodContext) && Boolean(document.documentMode)
+
+ if (isIE11) {
+ assert.expect(1)
+ } else {
+ assert.expect(2)
+ }
+
var done = assert.async()
var $modal = $([
@@ -759,14 +766,18 @@ $(function () {
done()
}
- document.addEventListener('focusin', focusInListener)
+ if (isIE11) {
+ done()
+ } else {
+ document.addEventListener('focusin', focusInListener)
- var focusInEvent = new Event('focusin')
- Object.defineProperty(focusInEvent, 'target', {
- value: $('#qunit-fixture')[0]
- })
+ var focusInEvent = new Event('focusin')
+ Object.defineProperty(focusInEvent, 'target', {
+ value: $('#qunit-fixture')[0]
+ })
- document.dispatchEvent(focusInEvent)
+ document.dispatchEvent(focusInEvent)
+ }
})
.bootstrapModal('show')
})
diff --git a/js/tests/unit/tests-polyfills.js b/js/tests/unit/tests-polyfills.js
new file mode 100644
index 000000000..4f2583e0d
--- /dev/null
+++ b/js/tests/unit/tests-polyfills.js
@@ -0,0 +1,28 @@
+// Polyfills for our unit tests
+(function () {
+ 'use strict'
+
+ // Event constructor shim
+ if (!window.Event || typeof window.Event !== 'function') {
+ var origEvent = window.Event
+ window.Event = function (inType, params) {
+ params = params || {}
+ var e = document.createEvent('Event')
+ e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable))
+ return e
+ }
+
+ window.Event.prototype = origEvent.prototype
+ }
+
+ if (typeof window.CustomEvent !== 'function') {
+ window.CustomEvent = function (event, params) {
+ params = params || { bubbles: false, cancelable: false, detail: null }
+ var evt = document.createEvent('CustomEvent')
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)
+ return evt
+ }
+
+ CustomEvent.prototype = window.Event.prototype
+ }
+})()