Created
July 11, 2023 10:11
-
-
Save takunagai/cbc2f2d4c19ad579bcfb0b3d3c0271c2 to your computer and use it in GitHub Desktop.
[pollyfil: Bootstrap v5 for IE11] #Bootstrap #old
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<{* IE11 対応 for Bootstrap 5 (polyfill.io を使用) | |
* Fix preventDefault for IE | |
* @ref { @link https://polyfill.io/v3/ } | |
* リクエストの User-Agent ヘッダーを読み、要求元のブラウザに適した polyfills を返す | |
* このため、モダンブラウザでアクセスしてもコードは表示されない | |
* https://polyfill.io/v3/polyfill.min.js?features=es5 でもいける? *}> | |
<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js"></script> | |
<script> | |
(function() { | |
const workingDefaultPrevented = (function() { | |
const e = document.createEvent('CustomEvent'); | |
e.initEvent('Bootstrap', true, true); | |
e.preventDefault(); | |
return e.defaultPrevented; | |
})(); | |
if (!workingDefaultPrevented) { | |
const 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment