diff --git a/build/build-plugins.js b/build/build-plugins.js
index 22a179066986..d7450148027c 100644
--- a/build/build-plugins.js
+++ b/build/build-plugins.js
@@ -28,6 +28,11 @@ const plugins = [
const format = 'umd'
const rootPath = !TEST ? '../js/dist/' : '../js/coverage/dist/'
const bsPlugins = {
+ Data: path.resolve(__dirname, '../js/src/dom/data.js'),
+ EventHandler: path.resolve(__dirname, '../js/src/dom/eventHandler.js'),
+ Manipulator: path.resolve(__dirname, '../js/src/dom/manipulator.js'),
+ Polyfill: path.resolve(__dirname, '../js/src/dom/polyfill.js'),
+ SelectorEngine: path.resolve(__dirname, '../js/src/dom/selectorEngine.js'),
Alert: path.resolve(__dirname, '../js/src/alert.js'),
Button: path.resolve(__dirname, '../js/src/button.js'),
Carousel: path.resolve(__dirname, '../js/src/carousel.js'),
@@ -41,27 +46,113 @@ const bsPlugins = {
Util: path.resolve(__dirname, '../js/src/util.js')
}
-Object.keys(bsPlugins)
- .forEach((pluginKey) => {
- console.log(`Building ${pluginKey} plugin...`)
+const defaultPluginConfig = {
+ external: [
+ bsPlugins.Data,
+ bsPlugins.EventHandler,
+ bsPlugins.SelectorEngine,
+ bsPlugins.Util
+ ],
+ globals: {
+ [bsPlugins.Data]: 'Data',
+ [bsPlugins.EventHandler]: 'EventHandler',
+ [bsPlugins.SelectorEngine]: 'SelectorEngine',
+ [bsPlugins.Util]: 'Util'
+ }
+}
- const external = ['jquery', 'popper.js']
- const globals = {
- jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
- 'popper.js': 'Popper'
+function getConfigByPluginKey(pluginKey) {
+ if (
+ pluginKey === 'Data' ||
+ pluginKey === 'Manipulator' ||
+ pluginKey === 'Util'
+ ) {
+ return {
+ external: [],
+ globals: {}
}
+ }
- // Do not bundle Util in plugins
- if (pluginKey !== 'Util') {
- external.push(bsPlugins.Util)
- globals[bsPlugins.Util] = 'Util'
+ if (pluginKey === 'EventHandler' || pluginKey === 'SelectorEngine') {
+ return {
+ external: [
+ bsPlugins.Polyfill,
+ bsPlugins.Util
+ ],
+ globals: {
+ [bsPlugins.Polyfill]: 'Polyfill',
+ [bsPlugins.Util]: 'Util'
+ }
}
+ }
+
+ if (pluginKey === 'Polyfill') {
+ return {
+ external: [bsPlugins.Util],
+ globals: {
+ [bsPlugins.Util]: 'Util'
+ }
+ }
+ }
+
+ if (pluginKey === 'Alert' || pluginKey === 'Tab') {
+ return defaultPluginConfig
+ }
+
+ if (
+ pluginKey === 'Button' ||
+ pluginKey === 'Carousel' ||
+ pluginKey === 'Collapse' ||
+ pluginKey === 'Modal' ||
+ pluginKey === 'ScrollSpy'
+ ) {
+ const config = Object.assign(defaultPluginConfig)
+ config.external.push(bsPlugins.Manipulator)
+ config.globals[bsPlugins.Manipulator] = 'Manipulator'
+ return config
+ }
- // Do not bundle Tooltip in Popover
- if (pluginKey === 'Popover') {
- external.push(bsPlugins.Tooltip)
- globals[bsPlugins.Tooltip] = 'Tooltip'
+ if (pluginKey === 'Dropdown' || pluginKey === 'Tooltip') {
+ const config = Object.assign(defaultPluginConfig)
+ config.external.push(bsPlugins.Manipulator, 'popper.js')
+ config.globals[bsPlugins.Manipulator] = 'Manipulator'
+ config.globals['popper.js'] = 'Popper'
+ return config
+ }
+
+ if (pluginKey === 'Popover') {
+ return {
+ external: [
+ bsPlugins.Data,
+ bsPlugins.SelectorEngine,
+ bsPlugins.Tooltip,
+ bsPlugins.Util
+ ],
+ globals: {
+ [bsPlugins.Data]: 'Data',
+ [bsPlugins.SelectorEngine]: 'SelectorEngine',
+ [bsPlugins.Tooltip]: 'Tooltip',
+ [bsPlugins.Util]: 'Util'
+ }
}
+ }
+}
+
+Object.keys(bsPlugins)
+ .forEach((pluginKey) => {
+ console.log(`Building ${pluginKey} plugin...`)
+
+ const config = getConfigByPluginKey(pluginKey)
+ const external = config.external
+ const globals = config.globals
+
+ const pluginPath = [
+ 'Data',
+ 'EventHandler',
+ 'Manipulator',
+ 'Polyfill',
+ 'SelectorEngine'
+ ].includes(pluginKey) ? `${rootPath}/dom/` : rootPath
rollup.rollup({
input: bsPlugins[pluginKey],
@@ -73,7 +164,7 @@ Object.keys(bsPlugins)
name: pluginKey,
sourcemap: true,
globals,
- file: path.resolve(__dirname, `${rootPath}${pluginKey.toLowerCase()}.js`)
+ file: path.resolve(__dirname, `${pluginPath}${pluginKey.toLowerCase()}.js`)
})
.then(() => console.log(`Building ${pluginKey} plugin... Done !`))
.catch((err) => console.error(`${pluginKey}: ${err}`))
diff --git a/js/src/dom/data.js b/js/src/dom/data.js
index 2c11151257bd..2dfaad91a416 100644
--- a/js/src/dom/data.js
+++ b/js/src/dom/data.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.1.1): dom/data.js
+ * Bootstrap (v4.1.3): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
diff --git a/js/src/dom/eventHandler.js b/js/src/dom/eventHandler.js
index 17f6d077a6d3..1707c5f98402 100644
--- a/js/src/dom/eventHandler.js
+++ b/js/src/dom/eventHandler.js
@@ -3,7 +3,7 @@ import Util from '../util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.1.1): dom/eventHandler.js
+ * Bootstrap (v4.1.3): dom/eventHandler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -314,4 +314,19 @@ const EventHandler = (() => {
}
})()
+/* istanbul ignore next */
+// focusin and focusout polyfill
+if (Polyfill.focusIn) {
+ (() => {
+ function listenerFocus(event) {
+ EventHandler.trigger(event.target, 'focusin')
+ }
+ function listenerBlur(event) {
+ EventHandler.trigger(event.target, 'focusout')
+ }
+ EventHandler.on(document, 'focus', 'input', listenerFocus)
+ EventHandler.on(document, 'blur', 'input', listenerBlur)
+ })()
+}
+
export default EventHandler
diff --git a/js/src/dom/manipulator.js b/js/src/dom/manipulator.js
index db3113f88d6e..ad14e2914860 100644
--- a/js/src/dom/manipulator.js
+++ b/js/src/dom/manipulator.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.1.1): dom/manipulator.js
+ * Bootstrap (v4.1.3): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
diff --git a/js/src/dom/polyfill.js b/js/src/dom/polyfill.js
index c0c1139f0360..45defb76e74b 100644
--- a/js/src/dom/polyfill.js
+++ b/js/src/dom/polyfill.js
@@ -2,7 +2,7 @@ import Util from '../util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.1.1): dom/polyfill.js
+ * Bootstrap (v4.1.3): dom/polyfill.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
diff --git a/js/src/dom/selectorEngine.js b/js/src/dom/selectorEngine.js
index 55d2ce4bbc01..c2eec95a7eb7 100644
--- a/js/src/dom/selectorEngine.js
+++ b/js/src/dom/selectorEngine.js
@@ -3,7 +3,7 @@ import Util from '../util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.1.1): dom/selectorEngine.js
+ * Bootstrap (v4.1.3): dom/selectorEngine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
diff --git a/js/src/index.js b/js/src/index.js
index 1b9634c3ec9c..64f1ecee48e0 100644
--- a/js/src/index.js
+++ b/js/src/index.js
@@ -3,9 +3,7 @@ import Button from './button'
import Carousel from './carousel'
import Collapse from './collapse'
import Dropdown from './dropdown'
-import EventHandler from './dom/eventHandler'
import Modal from './modal'
-import Polyfill from './dom/polyfill'
import Popover from './popover'
import ScrollSpy from './scrollspy'
import Tab from './tab'
@@ -19,21 +17,6 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
-/* istanbul ignore next */
-// focusin and focusout polyfill
-if (Polyfill.focusIn) {
- (() => {
- function listenerFocus(event) {
- EventHandler.trigger(event.target, 'focusin')
- }
- function listenerBlur(event) {
- EventHandler.trigger(event.target, 'focusout')
- }
- EventHandler.on(document, 'focus', 'input', listenerFocus)
- EventHandler.on(document, 'blur', 'input', listenerBlur)
- })()
-}
-
export {
Util,
Alert,
diff --git a/js/tests/index.html b/js/tests/index.html
index 8d07d2105123..f076187812ce 100644
--- a/js/tests/index.html
+++ b/js/tests/index.html
@@ -106,12 +106,12 @@
+
-
diff --git a/js/tests/karma.conf.js b/js/tests/karma.conf.js
index bcd980a3be83..8e83fa3a44ad 100644
--- a/js/tests/karma.conf.js
+++ b/js/tests/karma.conf.js
@@ -21,12 +21,12 @@ module.exports = (config) => {
files: [
jqueryFile,
'site/docs/4.1/assets/js/vendor/popper.min.js',
+ 'js/coverage/dist/util.js',
+ 'js/coverage/dist/dom/polyfill.js',
'js/coverage/dist/dom/eventHandler.js',
'js/coverage/dist/dom/selectorEngine.js',
'js/coverage/dist/dom/data.js',
'js/coverage/dist/dom/manipulator.js',
- 'js/coverage/dist/util.js',
- 'js/coverage/dist/dom/polyfill.js',
'js/coverage/dist/dom/!(polyfill).js',
'js/coverage/dist/tooltip.js',
'js/coverage/dist/!(util|index|tooltip).js', // include all of our js/dist files except util.js, index.js and tooltip.js
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index 423b20a800ca..0902ca981e2a 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -543,7 +543,7 @@ $(function () {
$(document.body).trigger('click')
})
- $dropdown.trigger('click')
+ $dropdown[0].click()
})
QUnit.test('should fire hide and hidden event without a clickEvent if event type is not click', function (assert) {
@@ -573,12 +573,13 @@ $(function () {
})
.on('shown.bs.dropdown', function () {
assert.ok(true, 'shown was fired')
- $dropdown.trigger($.Event('keydown', {
- which: 27
- }))
+
+ var keyDown = new Event('keydown')
+ keyDown.which = 27
+ $dropdown[0].dispatchEvent(keyDown)
})
- $dropdown.trigger('click')
+ $dropdown[0].click()
})
QUnit.test('should ignore keyboard events within s and