mirror of
https://github.com/twbs/bootstrap.git
synced 2025-03-02 02:29:24 +01:00
Wrap our objects into IIFE
This commit is contained in:
parent
bcbea02886
commit
7c1d0a1097
@ -5,6 +5,15 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const Data = (() => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
* Constants
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
const mapData = (() => {
|
const mapData = (() => {
|
||||||
const storeData = {}
|
const storeData = {}
|
||||||
let id = 1
|
let id = 1
|
||||||
@ -45,7 +54,7 @@ const mapData = (() => {
|
|||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
const Data = {
|
return {
|
||||||
setData(instance, key, data) {
|
setData(instance, key, data) {
|
||||||
mapData.set(instance, key, data)
|
mapData.set(instance, key, data)
|
||||||
},
|
},
|
||||||
@ -56,5 +65,6 @@ const Data = {
|
|||||||
mapData.delete(instance, key)
|
mapData.delete(instance, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
export default Data
|
export default Data
|
||||||
|
@ -7,6 +7,14 @@ import Util from '../util'
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const EventHandler = (() => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
* Polyfills
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
// defaultPrevented is broken in IE.
|
// defaultPrevented is broken in IE.
|
||||||
// https://connect.microsoft.com/IE/feedback/details/790389/event-defaultprevented-returns-false-after-preventdefault-was-called
|
// https://connect.microsoft.com/IE/feedback/details/790389/event-defaultprevented-returns-false-after-preventdefault-was-called
|
||||||
const workingDefaultPrevented = (() => {
|
const workingDefaultPrevented = (() => {
|
||||||
@ -76,24 +84,26 @@ if (!window.Event || typeof window.Event !== 'function') {
|
|||||||
window.Event.prototype = origEvent.prototype
|
window.Event.prototype = origEvent.prototype
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
* Constants
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
const TransitionEndEvent = {
|
||||||
|
WebkitTransition : 'webkitTransitionEnd',
|
||||||
|
transition : 'transitionend'
|
||||||
|
}
|
||||||
const namespaceRegex = /[^.]*(?=\..*)\.|.*/
|
const namespaceRegex = /[^.]*(?=\..*)\.|.*/
|
||||||
const stripNameRegex = /\..*/
|
const stripNameRegex = /\..*/
|
||||||
const keyEventRegex = /^key/
|
const keyEventRegex = /^key/
|
||||||
const stripUidRegex = /::\d+$/
|
const stripUidRegex = /::\d+$/
|
||||||
|
const eventRegistry = {} // Events storage
|
||||||
// Events storage
|
|
||||||
const eventRegistry = {}
|
|
||||||
let uidEvent = 1
|
let uidEvent = 1
|
||||||
|
const customEvents = {
|
||||||
function getUidEvent(element, uid) {
|
mouseenter: 'mouseover',
|
||||||
return element.uidEvent = uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++
|
mouseleave: 'mouseout'
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEvent(element) {
|
|
||||||
const uid = getUidEvent(element)
|
|
||||||
return eventRegistry[uid] = eventRegistry[uid] || {}
|
|
||||||
}
|
|
||||||
|
|
||||||
const nativeEvents = [
|
const nativeEvents = [
|
||||||
'click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu',
|
'click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu',
|
||||||
'mousewheel', 'DOMMouseScroll',
|
'mousewheel', 'DOMMouseScroll',
|
||||||
@ -107,9 +117,20 @@ const nativeEvents = [
|
|||||||
'error', 'abort', 'scroll'
|
'error', 'abort', 'scroll'
|
||||||
]
|
]
|
||||||
|
|
||||||
const customEvents = {
|
/**
|
||||||
mouseenter: 'mouseover',
|
* ------------------------------------------------------------------------
|
||||||
mouseleave: 'mouseout'
|
* Private methods
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function getUidEvent(element, uid) {
|
||||||
|
return element.uidEvent = uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEvent(element) {
|
||||||
|
const uid = getUidEvent(element)
|
||||||
|
return eventRegistry[uid] = eventRegistry[uid] || {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixEvent(event) {
|
function fixEvent(event) {
|
||||||
@ -163,7 +184,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const EventHandler = {
|
return {
|
||||||
on(element, originalTypeEvent, handler, delegationFn) {
|
on(element, originalTypeEvent, handler, delegationFn) {
|
||||||
if (typeof originalTypeEvent !== 'string' ||
|
if (typeof originalTypeEvent !== 'string' ||
|
||||||
(typeof element === 'undefined' || element === null)) {
|
(typeof element === 'undefined' || element === null)) {
|
||||||
@ -326,6 +347,7 @@ const EventHandler = {
|
|||||||
return evt
|
return evt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
// focusin and focusout polyfill
|
// focusin and focusout polyfill
|
||||||
if (typeof window.onfocusin === 'undefined') {
|
if (typeof window.onfocusin === 'undefined') {
|
||||||
|
@ -5,6 +5,15 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const SelectorEngine = (() => {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
* Polyfills
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
// matches polyfill (see: https://mzl.la/2ikXneG)
|
// matches polyfill (see: https://mzl.la/2ikXneG)
|
||||||
let fnMatches = null
|
let fnMatches = null
|
||||||
if (!Element.prototype.matches) {
|
if (!Element.prototype.matches) {
|
||||||
@ -41,7 +50,7 @@ if (!Element.prototype.closest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SelectorEngine = {
|
return {
|
||||||
matches(element, selector) {
|
matches(element, selector) {
|
||||||
return fnMatches.call(element, selector)
|
return fnMatches.call(element, selector)
|
||||||
},
|
},
|
||||||
@ -76,5 +85,6 @@ const SelectorEngine = {
|
|||||||
return fnClosest(element, selector)
|
return fnClosest(element, selector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
export default SelectorEngine
|
export default SelectorEngine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user