1
|
{"version":3,"file":"polyfill.js","sources":["../../src/util/index.js","../../src/dom/polyfill.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.3.1): util/index.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst MAX_UID = 1000000\nconst MILLISECONDS_MULTIPLIER = 1000\nconst TRANSITION_END = 'transitionend'\nconst jQuery = window.jQuery\n\n// Shoutout AngusCroll (https://goo.gl/pxwQGp)\nconst toType = (obj) => ({}.toString.call(obj).match(/\\s([a-z]+)/i)[1].toLowerCase())\n\n/**\n * --------------------------------------------------------------------------\n * Public Util Api\n * --------------------------------------------------------------------------\n */\n\nconst getUID = (prefix) => {\n do {\n // eslint-disable-next-line no-bitwise\n prefix += ~~(Math.random() * MAX_UID) // \"~~\" acts like a faster Math.floor() here\n } while (document.getElementById(prefix))\n return prefix\n}\n\nconst getSelectorFromElement = (element) => {\n let selector = element.getAttribute('data-target')\n\n if (!selector || selector === '#') {\n const hrefAttr = element.getAttribute('href')\n\n selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : ''\n }\n\n try {\n return document.querySelector(selector) ? selector : null\n } catch (err) {\n return null\n }\n}\n\nconst getTransitionDurationFromElement = (element) => {\n if (!element) {\n return 0\n }\n\n // Get transition-duration of the element\n let {\n transitionDuration,\n transitionDelay\n } = window.getComputedStyle(element)\n\n const floatTransitionDuration = parseFloat(transitionDuration)\n const floatTransitionDelay = parseFloat(transitionDelay)\n\n // Return 0 if element or transition duration is not found\n if (!floatTransitionDuration && !floatTransitionDelay) {\n return 0\n }\n\n // If multiple durations are defined, take the first\n transitionDuration = transitionDuration.split(',')[0]\n transitionDelay = transitionDelay.split(',')[0]\n\n return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER\n}\n\nconst triggerTransitionEnd = (element) => {\n element.dispatchEvent(new Event(TRANSITION_END))\n}\n\nconst isElement = (obj) => (obj[0] || obj).nodeType\n\nconst emulateTransitionEnd = (element, duration) => {\n let called = false\n const durationPadding = 5\n const emulatedDuration = duration + durationPadding\n function listener() {\n called = true\n element.removeEventListener(TRANSITION_END, listener)\n }\n\n element.addEventListener(TRANSITION_END, listener)\n setTimeout(() => {\n if (!called) {\n triggerTransitionEnd(element)\n }\n }, emulatedDuration)\n}\n\nconst typeCheckConfig = (componentName, config, configTypes) => {\n Object.keys(configTypes)\n .forEach((property) => {\n const expectedTypes = configTypes[property]\n const value = config[property]\n const valueType = value && isElement(value)\n ? 'element' : toType(value)\n\n if (!new RegExp(expectedTypes).test(valueType)) {\n throw new Error(\n `${componentName.toUpperCase()}: ` +\n `Option \"${property}\" provided type \"${valueType}\" ` +\n `but expected type \"${expectedTypes}\".`)\n }\n })\n}\n\nconst makeArray = (nodeList) => {\n if (!nodeList) {\n return []\n }\n\n return [].slice.call(nodeList)\n}\n\nconst isVisible = (element) => {\n if (!element) {\n return false\n }\n\n if (element.style && element.parentNode && element.parentNode.style) {\n return element.style.display !== 'none' &&\n element.parentNode.style.display !== 'none' &&\n element.style.visibility !== 'hidden'\n }\n\n return false\n}\n\nconst findShadowRoot = (element) => {\n if (!document.documentElement.attachShadow) {\n return null\n }\n\n // Can find the shadow root otherwise it'll return the document\n if (typeof element.getRootNode === 'function') {\n const root = element.getRootNode()\n return root instanceof ShadowRoot ? root : null\n }\n\n if (element instanceof ShadowRoot) {\n return element\n }\n\n // when we don't find a shadow root\n if (!element.parentNode) {\n return null\n }\n\n return findShadowRoot(element.parentNode)\n}\n\n// eslint-disable-next-line no-empty-function\nconst noop = () => function () {}\n\nconst reflow = (element) => element.offsetHeight\n\nexport {\n jQuery,\n TRANSITION_END,\n getUID,\n getSelectorFromElement,\n getTransitionDurationFromElement,\n triggerTransitionEnd,\n isElement,\n emulateTransitionEnd,\n typeCheckConfig,\n makeArray,\n isVisible,\n findShadowRoot,\n noop,\n reflow\n}\n","/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.3.1): dom/polyfill.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport {\n getUID\n} from '../util/index'\n\n/* istanbul ignore next */\nconst Polyfill = (() => {\n // MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached\n const defaultPreventedPreservedOnDispatch = (() => {\n const e = new CustomEvent('Bootstrap', {\n cancelable: true\n })\n\n const element = document.createElement('div')\n element.addEventListener('Bootstrap', () => null)\n\n e.preventDefault()\n element.dispatchEvent(e)\n return e.defaultPrevented\n })()\n\n let find = Element.prototype.querySelectorAll\n let findOne = Element.prototype.querySelector\n\n const scopeSelectorRegex = /:scope\\b/\n const supportScopeQuery = (() => {\n const element = document.createElement('div')\n\n try {\n element.querySelectorAll(':scope *')\n } catch (e) {\n return false\n }\n\n return true\n })()\n\n if (!supportScopeQuery) {\n find = function (selector) {\n if (!scopeSelectorRegex.test(selector)) {\n return this.querySelectorAll(selector)\n }\n\n const hasId = Boolean(this.id)\n\n if (!hasId) {\n this.id = getUID('scope')\n }\n\n let nodeList = null\n try {\n selector = selector.replace(scopeSelectorRegex, `#${this.id}`)\n nodeList = this.querySelectorAll(selector)\n } finally {\n if (!hasId) {\n this.removeAttribute('id')\n }\n }\n\n return nodeList\n }\n\n findOne = function (selector) {\n if (!scopeSelectorRegex.test(selector)) {\n return this.querySelector(selector)\n }\n\n const matches = find.call(this, selector)\n\n if (typeof matches[0] !== 'undefined') {\n return matches[0]\n }\n\n return null\n }\n }\n\n return {\n defaultPreventedPreservedOnDispatch,\n find,\n findOne\n }\n})()\n\nexport default Polyfill\n"],"names":["MAX_UID","jQuery","window","getUID","prefix","Math","random","document","getElementById","Polyfill","defaultPreventedPreservedOnDispatch","e","CustomEvent","cancelable","element","createElement","addEventListener","preventDefault","dispatchEvent","defaultPrevented","find","Element","prototype","querySelectorAll","findOne","querySelector","scopeSelectorRegex","supportScopeQuery","selector","test","hasId","Boolean","id","nodeList","replace","removeAttrib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