]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Revert "Revert "Add information about IE 11 compatibility.""
authorXhmikosR <xhmikosr@gmail.com>
Mon, 9 Mar 2020 12:52:53 +0000 (14:52 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Wed, 18 Mar 2020 18:59:27 +0000 (20:59 +0200)
This reverts commit bcf76ef5f0d6305bb8aa7a83ae7fdc45256f7f08.

site/content/docs/4.3/getting-started/javascript.md

index 3c5eecf360e0a6bf02f5321a3d4a729d509657ee..f02ea5bc7b7b64867b32dd7d371a089b4e7ab0af 100644 (file)
@@ -227,3 +227,40 @@ var tooltip = new bootstrap.Tooltip(yourTooltipEl, {
   }
 })
 {{< /highlight >}}
+
+## Compatibility with IE 11
+
+Bootstrap v5 isn't designed to work with Internet Explorer 11, but you can add the following polyfills to make it work:
+
+{{< highlight html >}}
+<!-- Polyfill.io will load polyfills your browser needs -->
+<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js"></script>
+<script>
+  // Fix preventDefault for IE
+  (function () {
+    var workingDefaultPrevented = (function () {
+      var e = document.createEvent('CustomEvent')
+      e.initEvent('Bootstrap', true, true)
+      e.preventDefault()
+      return e.defaultPrevented
+    })()
+
+    if (!workingDefaultPrevented) {
+      var origPreventDefault = Event.prototype.preventDefault
+      Event.prototype.preventDefault = function () {
+        if (!this.cancelable) {
+          return
+        }
+
+        origPreventDefault.call(this)
+        Object.defineProperty(this, 'defaultPrevented', {
+          get: function () {
+            return true
+          },
+          configurable: true
+        })
+      }
+    }
+  })()
+</script>
+{{< /highlight >}}