Skip to content

Commit

Permalink
chore(update): bump to 4.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S committed Aug 12, 2018
1 parent 345a5e9 commit 97db24b
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 47 deletions.
123 changes: 107 additions & 16 deletions build/build-plugins.js
Expand Up @@ -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'),
Expand All @@ -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],
Expand All @@ -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}`))
Expand Down
2 changes: 1 addition & 1 deletion 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)
* --------------------------------------------------------------------------
*/
Expand Down
17 changes: 16 additions & 1 deletion js/src/dom/eventHandler.js
Expand Up @@ -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)
* --------------------------------------------------------------------------
*/
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion 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)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion js/src/dom/polyfill.js
Expand Up @@ -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)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion js/src/dom/selectorEngine.js
Expand Up @@ -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)
* --------------------------------------------------------------------------
*/
Expand Down
17 changes: 0 additions & 17 deletions js/src/index.js
Expand Up @@ -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'
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion js/tests/index.html
Expand Up @@ -106,12 +106,12 @@
</script>

<!-- Transpiled Plugins -->
<script src="../dist/util.js"></script>
<script src="../dist/dom/polyfill.js"></script>
<script src="../dist/dom/manipulator.js"></script>
<script src="../dist/dom/eventHandler.js"></script>
<script src="../dist/dom/selectorEngine.js"></script>
<script src="../dist/dom/data.js"></script>
<script src="../dist/util.js"></script>
<script src="../dist/alert.js"></script>
<script src="../dist/button.js"></script>
<script src="../dist/carousel.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions js/tests/karma.conf.js
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions js/tests/unit/dropdown.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 <input>s and <textarea>s', function (assert) {
Expand Down
2 changes: 1 addition & 1 deletion js/tests/unit/tooltip.js
Expand Up @@ -951,7 +951,7 @@ $(function () {
var $tipTest = $('<div class="bs-tooltip" />')
.appendTo('#qunit-fixture')

var tooltip = $tooltip.data('bs.tooltip')
var tooltip = Tooltip._getInstance($tooltip[0])
tooltip.tip = null

tooltip._handlePopperPlacementChange({
Expand Down

0 comments on commit 97db24b

Please sign in to comment.