mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-30 22:52:24 +01:00
Remove IE compatibility JS code
This commit is contained in:
parent
bc3f82863b
commit
47aef7b2c6
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { getjQuery } from '../util/index'
|
||||
import { createCustomEvent, defaultPreventedPreservedOnDispatch } from './polyfill'
|
||||
import { defaultPreventedPreservedOnDispatch } from './polyfill'
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
@ -307,7 +307,7 @@ const EventHandler = {
|
||||
evt = document.createEvent('HTMLEvents')
|
||||
evt.initEvent(typeEvent, bubbles, true)
|
||||
} else {
|
||||
evt = createCustomEvent(event, {
|
||||
evt = new CustomEvent(event, {
|
||||
bubbles,
|
||||
cancelable: true
|
||||
})
|
||||
|
@ -9,55 +9,12 @@
|
||||
|
||||
import { getUID } from '../util/index'
|
||||
|
||||
let { matches, closest } = Element.prototype
|
||||
let find = Element.prototype.querySelectorAll
|
||||
let findOne = Element.prototype.querySelector
|
||||
let createCustomEvent = (eventName, params) => {
|
||||
const cEvent = new CustomEvent(eventName, params)
|
||||
|
||||
return cEvent
|
||||
}
|
||||
|
||||
if (typeof window.CustomEvent !== 'function') {
|
||||
createCustomEvent = (eventName, params) => {
|
||||
params = params || { bubbles: false, cancelable: false, detail: null }
|
||||
|
||||
const evt = document.createEvent('CustomEvent')
|
||||
|
||||
evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail)
|
||||
return evt
|
||||
}
|
||||
}
|
||||
|
||||
const workingDefaultPrevented = (() => {
|
||||
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() {
|
||||
return true
|
||||
},
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
|
||||
const defaultPreventedPreservedOnDispatch = (() => {
|
||||
const e = createCustomEvent('Bootstrap', {
|
||||
const e = new CustomEvent('Bootstrap', {
|
||||
cancelable: true
|
||||
})
|
||||
|
||||
@ -69,26 +26,6 @@ const defaultPreventedPreservedOnDispatch = (() => {
|
||||
return e.defaultPrevented
|
||||
})()
|
||||
|
||||
if (!matches) {
|
||||
matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector
|
||||
}
|
||||
|
||||
if (!closest) {
|
||||
closest = function (selector) {
|
||||
let element = this
|
||||
|
||||
do {
|
||||
if (matches.call(element, selector)) {
|
||||
return element
|
||||
}
|
||||
|
||||
element = element.parentElement || element.parentNode
|
||||
} while (element !== null && element.nodeType === 1)
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const scopeSelectorRegex = /:scope\b/
|
||||
const supportScopeQuery = (() => {
|
||||
const element = document.createElement('div')
|
||||
@ -143,10 +80,7 @@ if (!supportScopeQuery) {
|
||||
}
|
||||
|
||||
export {
|
||||
createCustomEvent,
|
||||
find,
|
||||
findOne,
|
||||
matches,
|
||||
closest,
|
||||
defaultPreventedPreservedOnDispatch
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import { find as findFn, findOne, matches, closest } from './polyfill'
|
||||
import { find as findFn, findOne } from './polyfill'
|
||||
import { makeArray } from '../util/index'
|
||||
|
||||
/**
|
||||
@ -18,7 +18,7 @@ const NODE_TEXT = 3
|
||||
|
||||
const SelectorEngine = {
|
||||
matches(element, selector) {
|
||||
return matches.call(element, selector)
|
||||
return element.matches(selector)
|
||||
},
|
||||
|
||||
find(selector, element = document.documentElement) {
|
||||
@ -52,7 +52,7 @@ const SelectorEngine = {
|
||||
},
|
||||
|
||||
closest(element, selector) {
|
||||
return closest.call(element, selector)
|
||||
return element.closest(selector)
|
||||
},
|
||||
|
||||
prev(element, selector) {
|
||||
|
@ -87,10 +87,7 @@ const getTransitionDurationFromElement = element => {
|
||||
}
|
||||
|
||||
const triggerTransitionEnd = element => {
|
||||
const evt = document.createEvent('HTMLEvents')
|
||||
|
||||
evt.initEvent(TRANSITION_END, true, true)
|
||||
element.dispatchEvent(evt)
|
||||
element.dispatchEvent(new Event(TRANSITION_END))
|
||||
}
|
||||
|
||||
const isElement = obj => (obj[0] || obj).nodeType
|
||||
|
@ -30,13 +30,6 @@ const browsers = {
|
||||
browser: 'Edge',
|
||||
browser_version: 'latest'
|
||||
},
|
||||
ie11Win10: {
|
||||
base: 'BrowserStack',
|
||||
os: 'Windows',
|
||||
os_version: '10',
|
||||
browser: 'IE',
|
||||
browser_version: '11.0'
|
||||
},
|
||||
chromeWin10: {
|
||||
base: 'BrowserStack',
|
||||
os: 'Windows',
|
||||
|
Loading…
x
Reference in New Issue
Block a user