diff --git a/assets/js/src/application.js b/assets/js/src/application.js index d5ee22ebc3..01c9eef55b 100644 --- a/assets/js/src/application.js +++ b/assets/js/src/application.js @@ -16,7 +16,6 @@ 'use strict' $(function () { - // Tooltip and popover demos $('.tooltip-demo').tooltip({ selector: '[data-toggle="tooltip"]', @@ -60,7 +59,7 @@ $('.btn-clipboard') .tooltip() .on('mouseleave', function () { - // explicitly hide tooltip, since after clicking it remains + // Explicitly hide tooltip, since after clicking it remains // focused (as it's a button), so tooltip would otherwise // remain visible until focus is moved away $(this).tooltip('hide') diff --git a/assets/js/src/pwa.js b/assets/js/src/pwa.js index 3484f05b04..22a0dde6d7 100644 --- a/assets/js/src/pwa.js +++ b/assets/js/src/pwa.js @@ -1,6 +1,6 @@ /* eslint no-console:off */ -(function setupSW() { +(function () { 'use strict' if ('serviceWorker' in navigator) { diff --git a/build/change-version.js b/build/change-version.js index ab4579072b..dc0b0c5dfd 100755 --- a/build/change-version.js +++ b/build/change-version.js @@ -18,8 +18,13 @@ const sh = require('shelljs') sh.config.fatal = true // Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37 -RegExp.quote = (string) => string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&') -RegExp.quoteReplacement = (string) => string.replace(/[$]/g, '$$') +function regExpQuote(string) { + return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&') +} + +function regExpQuoteReplacement(string) { + return string.replace(/[$]/g, '$$') +} const DRY_RUN = false @@ -39,13 +44,9 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) { process.nextTick(errback, err) return } - if (stats.isSymbolicLink()) { - return - } - else if (stats.isDirectory()) { + if (stats.isDirectory()) { process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback) - } - else if (stats.isFile()) { + } else if (stats.isFile()) { process.nextTick(fileCallback, filepath) } }) @@ -54,18 +55,17 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) { } function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { - original = new RegExp(RegExp.quote(original), 'g') - replacement = RegExp.quoteReplacement(replacement) - const updateFile = !DRY_RUN ? (filepath) => { + original = new RegExp(regExpQuote(original), 'g') + replacement = regExpQuoteReplacement(replacement) + const updateFile = DRY_RUN ? (filepath) => { if (allowedExtensions.has(path.parse(filepath).ext)) { - sh.sed('-i', original, replacement, filepath) + console.log(`FILE: ${filepath}`) + } else { + console.log(`EXCLUDED:${filepath}`) } } : (filepath) => { if (allowedExtensions.has(path.parse(filepath).ext)) { - console.log(`FILE: ${filepath}`) - } - else { - console.log(`EXCLUDED:${filepath}`) + sh.sed('-i', original, replacement, filepath) } } walkAsync(directory, excludedDirectories, updateFile, (err) => { diff --git a/build/generate-sri.js b/build/generate-sri.js index 708e6dfbf8..2ace46e05f 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -55,6 +55,6 @@ files.forEach((file) => { console.log(`${file.configPropertyName}: ${integrity}`) - sh.sed('-i', new RegExp(`(\\s${file.configPropertyName}:\\s+"|')(\\S+)("|')`), '$1' + integrity + '$3', configFile) + sh.sed('-i', new RegExp(`(\\s${file.configPropertyName}:\\s+"|')(\\S+)("|')`), `$1${integrity}$3`, configFile) }) }) diff --git a/build/postcss.config.js b/build/postcss.config.js index c7c9a17b05..157291ffd2 100644 --- a/build/postcss.config.js +++ b/build/postcss.config.js @@ -7,6 +7,8 @@ module.exports = (ctx) => ({ sourcesContent: true }, plugins: { - autoprefixer: { cascade: false } + autoprefixer: { + cascade: false + } } }) diff --git a/build/rollup.config.js b/build/rollup.config.js index 0b59aef652..c97e3761c1 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -3,16 +3,17 @@ const path = require('path') const babel = require('rollup-plugin-babel') const resolve = require('rollup-plugin-node-resolve') + const pkg = require(path.resolve(__dirname, '../package.json')) const BUNDLE = process.env.BUNDLE === 'true' const year = new Date().getFullYear() let fileDest = 'bootstrap.js' -const external = ['jquery', 'popper.js'] +const external = ['jquery', 'popper.js'] const plugins = [ babel({ - exclude: 'node_modules/**', // only transpile our source code - externalHelpersWhitelist: [ // include only required helpers + exclude: 'node_modules/**', // Only transpile our source code + externalHelpersWhitelist: [ // Include only required helpers 'defineProperties', 'createClass', 'inheritsLoose', @@ -21,13 +22,13 @@ const plugins = [ }) ] const globals = { - jquery: 'jQuery', // ensure we use jQuery which is always available even in noConflict mode + jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode 'popper.js': 'Popper' } if (BUNDLE) { fileDest = 'bootstrap.bundle.js' - // remove last entry in external array to bundle Popper + // Remove last entry in external array to bundle Popper external.pop() delete globals['popper.js'] plugins.push(resolve()) diff --git a/build/saucelabs-unit-test.js b/build/saucelabs-unit-test.js index 0b4a3b5f0e..3ec68a95b2 100644 --- a/build/saucelabs-unit-test.js +++ b/build/saucelabs-unit-test.js @@ -91,7 +91,7 @@ jsUnitSaucelabs.on('tunnelCreated', () => { if (typeof success !== 'undefined') { const taskIds = success['js tests'] - if (!taskIds || !taskIds.length) { + if (!taskIds || taskIds.length === 0) { throw new Error('Error starting tests through Sauce Labs API') } diff --git a/build/vnu-jar.js b/build/vnu-jar.js index 991d5c1c09..eefcb64ebf 100644 --- a/build/vnu-jar.js +++ b/build/vnu-jar.js @@ -64,5 +64,5 @@ childProcess.exec('java -version', (error, stdout, stderr) => { shell: true, stdio: 'inherit' }) - .on('exit', process.exit) + .on('exit', process.exit) }) diff --git a/build/workbox.js b/build/workbox.js index 17129ec8c3..e51cf6dcbd 100644 --- a/build/workbox.js +++ b/build/workbox.js @@ -4,6 +4,7 @@ const fs = require('fs') const path = require('path') const swBuild = require('workbox-build') const config = require('./workbox.config.json') + const buildPrefix = '_gh_pages/' const workboxSWSrcPath = require.resolve('workbox-sw') diff --git a/js/src/alert.js b/js/src/alert.js index 9f17d5ed0e..147701bfe2 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -1,7 +1,6 @@ import $ from 'jquery' import Util from './util' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta.3): alert.js @@ -10,8 +9,6 @@ import Util from './util' */ const Alert = (($) => { - - /** * ------------------------------------------------------------------------ * Constants @@ -42,7 +39,6 @@ const Alert = (($) => { SHOW : 'show' } - /** * ------------------------------------------------------------------------ * Class Definition @@ -50,20 +46,17 @@ const Alert = (($) => { */ class Alert { - constructor(element) { this._element = element } - - // getters + // Getters static get VERSION() { return VERSION } - - // public + // Public close(element) { element = element || this._element @@ -83,8 +76,7 @@ const Alert = (($) => { this._element = null } - - // private + // Private _getRootElement(element) { const selector = Util.getSelectorFromElement(element) @@ -129,8 +121,7 @@ const Alert = (($) => { .remove() } - - // static + // Static static _jQueryInterface(config) { return this.each(function () { @@ -157,10 +148,8 @@ const Alert = (($) => { alertInstance.close(this) } } - } - /** * ------------------------------------------------------------------------ * Data Api implementation @@ -173,7 +162,6 @@ const Alert = (($) => { Alert._handleDismiss(new Alert()) ) - /** * ------------------------------------------------------------------------ * jQuery @@ -188,7 +176,6 @@ const Alert = (($) => { } return Alert - })($) export default Alert diff --git a/js/src/button.js b/js/src/button.js index 56688e2462..445e78938b 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -8,8 +8,6 @@ import $ from 'jquery' */ const Button = (($) => { - - /** * ------------------------------------------------------------------------ * Constants @@ -39,11 +37,10 @@ const Button = (($) => { const Event = { CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`, - FOCUS_BLUR_DATA_API : `focus${EVENT_KEY}${DATA_API_KEY} ` - + `blur${EVENT_KEY}${DATA_API_KEY}` + FOCUS_BLUR_DATA_API : `focus${EVENT_KEY}${DATA_API_KEY} ` + + `blur${EVENT_KEY}${DATA_API_KEY}` } - /** * ------------------------------------------------------------------------ * Class Definition @@ -51,25 +48,22 @@ const Button = (($) => { */ class Button { - constructor(element) { this._element = element } - - // getters + // Getters static get VERSION() { return VERSION } - - // public + // Public toggle() { let triggerChangeEvent = true let addAriaPressed = true - const rootElement = $(this._element).closest( + const rootElement = $(this._element).closest( Selector.DATA_TOGGLE )[0] @@ -81,7 +75,6 @@ const Button = (($) => { if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) { triggerChangeEvent = false - } else { const activeElement = $(rootElement).find(Selector.ACTIVE)[0] @@ -105,7 +98,6 @@ const Button = (($) => { input.focus() addAriaPressed = false } - } if (addAriaPressed) { @@ -123,8 +115,7 @@ const Button = (($) => { this._element = null } - - // static + // Static static _jQueryInterface(config) { return this.each(function () { @@ -140,10 +131,8 @@ const Button = (($) => { } }) } - } - /** * ------------------------------------------------------------------------ * Data Api implementation @@ -167,22 +156,20 @@ const Button = (($) => { $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)) }) - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ - $.fn[NAME] = Button._jQueryInterface + $.fn[NAME] = Button._jQueryInterface $.fn[NAME].Constructor = Button - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return Button._jQueryInterface } return Button - })($) export default Button diff --git a/js/src/carousel.js b/js/src/carousel.js index 083f2548e4..895d4dd3bf 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -1,7 +1,6 @@ import $ from 'jquery' import Util from './util' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta.3): carousel.js @@ -10,8 +9,6 @@ import Util from './util' */ const Carousel = (($) => { - - /** * ------------------------------------------------------------------------ * Constants @@ -84,7 +81,6 @@ const Carousel = (($) => { DATA_RIDE : '[data-ride="carousel"]' } - /** * ------------------------------------------------------------------------ * Class Definition @@ -92,7 +88,6 @@ const Carousel = (($) => { */ class Carousel { - constructor(element, config) { this._items = null this._interval = null @@ -110,8 +105,7 @@ const Carousel = (($) => { this._addEventListeners() } - - // getters + // Getters static get VERSION() { return VERSION @@ -121,8 +115,7 @@ const Carousel = (($) => { return Default } - - // public + // Public next() { if (!this._isSliding) { @@ -198,9 +191,9 @@ const Carousel = (($) => { return } - const direction = index > activeIndex ? - Direction.NEXT : - Direction.PREV + const direction = index > activeIndex + ? Direction.NEXT + : Direction.PREV this._slide(direction, this._items[index]) } @@ -219,8 +212,7 @@ const Carousel = (($) => { this._indicatorsElement = null } - - // private + // Private _getConfig(config) { config = { @@ -242,7 +234,7 @@ const Carousel = (($) => { .on(Event.MOUSEENTER, (event) => this.pause(event)) .on(Event.MOUSELEAVE, (event) => this.cycle(event)) if ('ontouchstart' in document.documentElement) { - // if it's a touch-enabled device, mouseenter/leave are fired as + // If it's a touch-enabled device, mouseenter/leave are fired as // part of the mouse compatibility events on first tap - the carousel // would stop cycling until user tapped out of it; // here, we listen for touchend, explicitly pause the carousel @@ -275,7 +267,6 @@ const Carousel = (($) => { this.next() break default: - return } } @@ -299,11 +290,10 @@ const Carousel = (($) => { const delta = direction === Direction.PREV ? -1 : 1 const itemIndex = (activeIndex + delta) % this._items.length - return itemIndex === -1 ? - this._items[this._items.length - 1] : this._items[itemIndex] + return itemIndex === -1 + ? this._items[this._items.length - 1] : this._items[itemIndex] } - _triggerSlideEvent(relatedTarget, eventDirectionName) { const targetIndex = this._getItemIndex(relatedTarget) const fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]) @@ -368,7 +358,7 @@ const Carousel = (($) => { } if (!activeElement || !nextElement) { - // some weirdness is happening, so we bail + // Some weirdness is happening, so we bail return } @@ -389,7 +379,6 @@ const Carousel = (($) => { if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) { - $(nextElement).addClass(orderClassName) Util.reflow(nextElement) @@ -408,10 +397,8 @@ const Carousel = (($) => { this._isSliding = false setTimeout(() => $(this._element).trigger(slidEvent), 0) - }) .emulateTransitionEnd(TRANSITION_DURATION) - } else { $(activeElement).removeClass(ClassName.ACTIVE) $(nextElement).addClass(ClassName.ACTIVE) @@ -425,12 +412,11 @@ const Carousel = (($) => { } } - - // static + // Static static _jQueryInterface(config) { return this.each(function () { - let data = $(this).data(DATA_KEY) + let data = $(this).data(DATA_KEY) let _config = { ...Default, ...$(this).data() @@ -454,7 +440,7 @@ const Carousel = (($) => { data.to(config) } else if (typeof action === 'string') { if (typeof data[action] === 'undefined') { - throw new Error(`No method named "${action}"`) + throw new TypeError(`No method named "${action}"`) } data[action]() } else if (_config.interval) { @@ -495,10 +481,8 @@ const Carousel = (($) => { event.preventDefault() } - } - /** * ------------------------------------------------------------------------ * Data Api implementation @@ -515,22 +499,20 @@ const Carousel = (($) => { }) }) - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ - $.fn[NAME] = Carousel._jQueryInterface + $.fn[NAME] = Carousel._jQueryInterface $.fn[NAME].Constructor = Carousel - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return Carousel._jQueryInterface } return Carousel - })($) export default Carousel diff --git a/js/src/collapse.js b/js/src/collapse.js index b0c17112c6..eaaf155e1e 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -1,7 +1,6 @@ import $ from 'jquery' import Util from './util' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta.3): collapse.js @@ -10,8 +9,6 @@ import Util from './util' */ const Collapse = (($) => { - - /** * ------------------------------------------------------------------------ * Constants @@ -61,7 +58,6 @@ const Collapse = (($) => { DATA_TOGGLE : '[data-toggle="collapse"]' } - /** * ------------------------------------------------------------------------ * Class Definition @@ -69,7 +65,6 @@ const Collapse = (($) => { */ class Collapse { - constructor(element, config) { this._isTransitioning = false this._element = element @@ -99,8 +94,7 @@ const Collapse = (($) => { } } - - // getters + // Getters static get VERSION() { return VERSION @@ -110,8 +104,7 @@ const Collapse = (($) => { return Default } - - // public + // Public toggle() { if ($(this._element).hasClass(ClassName.SHOW)) { @@ -136,7 +129,7 @@ const Collapse = (($) => { .find(Selector.ACTIVES) .filter(`[data-parent="${this._config.parent}"]`) ) - if (!actives.length) { + if (actives.length === 0) { actives = null } } @@ -169,7 +162,7 @@ const Collapse = (($) => { this._element.style[dimension] = 0 - if (this._triggerArray.length) { + if (this._triggerArray.length > 0) { $(this._triggerArray) .removeClass(ClassName.COLLAPSED) .attr('aria-expanded', true) @@ -196,7 +189,7 @@ const Collapse = (($) => { } const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1) - const scrollSize = `scroll${capitalizedDimension}` + const scrollSize = `scroll${capitalizedDimension}` $(this._element) .one(Util.TRANSITION_END, complete) @@ -217,7 +210,7 @@ const Collapse = (($) => { return } - const dimension = this._getDimension() + const dimension = this._getDimension() this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px` @@ -228,7 +221,7 @@ const Collapse = (($) => { .removeClass(ClassName.COLLAPSE) .removeClass(ClassName.SHOW) - if (this._triggerArray.length) { + if (this._triggerArray.length > 0) { for (let i = 0; i < this._triggerArray.length; i++) { const trigger = this._triggerArray[i] const selector = Util.getSelectorFromElement(trigger) @@ -236,7 +229,7 @@ const Collapse = (($) => { const $elem = $(selector) if (!$elem.hasClass(ClassName.SHOW)) { $(trigger).addClass(ClassName.COLLAPSED) - .attr('aria-expanded', false) + .attr('aria-expanded', false) } } } @@ -278,15 +271,14 @@ const Collapse = (($) => { this._isTransitioning = null } - - // private + // Private _getConfig(config) { config = { ...Default, ...config } - config.toggle = Boolean(config.toggle) // coerce string values + config.toggle = Boolean(config.toggle) // Coerce string values Util.typeCheckConfig(NAME, config, DefaultType) return config } @@ -301,7 +293,7 @@ const Collapse = (($) => { if (Util.isElement(this._config.parent)) { parent = this._config.parent - // it's a jQuery object + // It's a jQuery object if (typeof this._config.parent.jquery !== 'undefined') { parent = this._config.parent[0] } @@ -326,7 +318,7 @@ const Collapse = (($) => { if (element) { const isOpen = $(element).hasClass(ClassName.SHOW) - if (triggerArray.length) { + if (triggerArray.length > 0) { $(triggerArray) .toggleClass(ClassName.COLLAPSED, !isOpen) .attr('aria-expanded', isOpen) @@ -334,8 +326,7 @@ const Collapse = (($) => { } } - - // static + // Static static _getTargetFromElement(element) { const selector = Util.getSelectorFromElement(element) @@ -363,16 +354,14 @@ const Collapse = (($) => { if (typeof config === 'string') { if (typeof data[config] === 'undefined') { - throw new Error(`No method named "${config}"`) + throw new TypeError(`No method named "${config}"`) } data[config]() } }) } - } - /** * ------------------------------------------------------------------------ * Data Api implementation @@ -395,22 +384,20 @@ const Collapse = (($) => { }) }) - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ - $.fn[NAME] = Collapse._jQueryInterface + $.fn[NAME] = Collapse._jQueryInterface $.fn[NAME].Constructor = Collapse - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return Collapse._jQueryInterface } return Collapse - })($) export default Collapse diff --git a/js/src/dropdown.js b/js/src/dropdown.js index a2505c0b54..863f7812e5 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -2,7 +2,6 @@ import $ from 'jquery' import Popper from 'popper.js' import Util from './util' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta.3): dropdown.js @@ -11,7 +10,6 @@ import Util from './util' */ const Dropdown = (($) => { - /** * ------------------------------------------------------------------------ * Constants @@ -85,7 +83,6 @@ const Dropdown = (($) => { boundary : '(string|element)' } - /** * ------------------------------------------------------------------------ * Class Definition @@ -93,7 +90,6 @@ const Dropdown = (($) => { */ class Dropdown { - constructor(element, config) { this._element = element this._popper = null @@ -104,8 +100,7 @@ const Dropdown = (($) => { this._addEventListeners() } - - // getters + // Getters static get VERSION() { return VERSION @@ -119,7 +114,7 @@ const Dropdown = (($) => { return DefaultType } - // public + // Public toggle() { if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) { @@ -136,7 +131,7 @@ const Dropdown = (($) => { } const relatedTarget = { - relatedTarget : this._element + relatedTarget: this._element } const showEvent = $.Event(Event.SHOW, relatedTarget) @@ -153,10 +148,10 @@ const Dropdown = (($) => { * Popper - https://popper.js.org */ if (typeof Popper === 'undefined') { - throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)') + throw new TypeError('Bootstrap dropdown require Popper.js (https://popper.js.org)') } let element = this._element - // for dropup with alignment we use the parent as popper container + // For dropup with alignment we use the parent as popper container if ($(parent).hasClass(ClassName.DROPUP)) { if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) { element = parent @@ -171,13 +166,12 @@ const Dropdown = (($) => { this._popper = new Popper(element, this._menu, this._getPopperConfig()) } - - // if this is a touch-enabled device we add extra + // If this is a touch-enabled device we add extra // empty mouseover listeners to the body's immediate children; // only needed because of broken event delegation on iOS // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html if ('ontouchstart' in document.documentElement && - !$(parent).closest(Selector.NAVBAR_NAV).length) { + $(parent).closest(Selector.NAVBAR_NAV).length === 0) { $('body').children().on('mouseover', null, $.noop) } @@ -208,7 +202,7 @@ const Dropdown = (($) => { } } - // private + // Private _addEventListeners() { $(this._element).on(Event.CLICK, (event) => { @@ -244,7 +238,7 @@ const Dropdown = (($) => { _getPlacement() { const $parentDropdown = $(this._element).parent() - let placement = AttachmentMap.BOTTOM + let placement = AttachmentMap.BOTTOM // Handle dropup if ($parentDropdown.hasClass(ClassName.DROPUP)) { @@ -280,14 +274,14 @@ const Dropdown = (($) => { offsetConf.offset = this._config.offset } const popperConfig = { - placement : this._getPlacement(), - modifiers : { - offset : offsetConf, - flip : { - enabled : this._config.flip + placement: this._getPlacement(), + modifiers: { + offset: offsetConf, + flip: { + enabled: this._config.flip }, - preventOverflow : { - boundariesElement : this._config.boundary + preventOverflow: { + boundariesElement: this._config.boundary } } } @@ -295,7 +289,7 @@ const Dropdown = (($) => { return popperConfig } - // static + // Static static _jQueryInterface(config) { return this.each(function () { @@ -309,7 +303,7 @@ const Dropdown = (($) => { if (typeof config === 'string') { if (typeof data[config] === 'undefined') { - throw new Error(`No method named "${config}"`) + throw new TypeError(`No method named "${config}"`) } data[config]() } @@ -324,10 +318,10 @@ const Dropdown = (($) => { const toggles = $.makeArray($(Selector.DATA_TOGGLE)) for (let i = 0; i < toggles.length; i++) { - const parent = Dropdown._getParentFromElement(toggles[i]) - const context = $(toggles[i]).data(DATA_KEY) + const parent = Dropdown._getParentFromElement(toggles[i]) + const context = $(toggles[i]).data(DATA_KEY) const relatedTarget = { - relatedTarget : toggles[i] + relatedTarget: toggles[i] } if (!context) { @@ -340,8 +334,8 @@ const Dropdown = (($) => { } if (event && (event.type === 'click' && - /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) - && $.contains(parent, event.target)) { + /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && + $.contains(parent, event.target)) { continue } @@ -351,7 +345,7 @@ const Dropdown = (($) => { continue } - // if this is a touch-enabled device we remove the extra + // If this is a touch-enabled device we remove the extra // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { $('body').children().off('mouseover', null, $.noop) @@ -386,8 +380,8 @@ const Dropdown = (($) => { // - If key is other than escape // - If key is not up or down => not a dropdown command // - If trigger inside the menu => not a dropdown command - if (/input|textarea/i.test(event.target.tagName) ? - event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && + if (/input|textarea/i.test(event.target.tagName) + ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { return @@ -405,7 +399,6 @@ const Dropdown = (($) => { if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { - if (event.which === ESCAPE_KEYCODE) { const toggle = $(parent).find(Selector.DATA_TOGGLE)[0] $(toggle).trigger('focus') @@ -417,17 +410,17 @@ const Dropdown = (($) => { const items = $(parent).find(Selector.VISIBLE_ITEMS).get() - if (!items.length) { + if (items.length === 0) { return } let index = items.indexOf(event.target) - if (event.which === ARROW_UP_KEYCODE && index > 0) { // up + if (event.which === ARROW_UP_KEYCODE && index > 0) { // Up index-- } - if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { // down + if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { // Down index++ } @@ -437,10 +430,8 @@ const Dropdown = (($) => { items[index].focus() } - } - /** * ------------------------------------------------------------------------ * Data Api implementation @@ -448,7 +439,7 @@ const Dropdown = (($) => { */ $(document) - .on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler) + .on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler) .on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler) .on(`${Event.CLICK_DATA_API} ${Event.KEYUP_DATA_API}`, Dropdown._clearMenus) .on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { @@ -460,22 +451,20 @@ const Dropdown = (($) => { e.stopPropagation() }) - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ - $.fn[NAME] = Dropdown._jQueryInterface + $.fn[NAME] = Dropdown._jQueryInterface $.fn[NAME].Constructor = Dropdown - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return Dropdown._jQueryInterface } return Dropdown - })($, Popper) export default Dropdown diff --git a/js/src/index.js b/js/src/index.js index 51d09b4e29..db504319c0 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -20,12 +20,12 @@ import Util from './util' (($) => { if (typeof $ === 'undefined') { - throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') + throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') } const version = $.fn.jquery.split(' ')[0].split('.') const minMajor = 1 - const ltMajor = 2 + const ltMajor = 2 const minMinor = 9 const minPatch = 1 const maxMajor = 4 diff --git a/js/src/modal.js b/js/src/modal.js index e98277a6dd..ef5994f986 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -1,7 +1,6 @@ import $ from 'jquery' import Util from './util' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta.3): modal.js @@ -10,8 +9,6 @@ import Util from './util' */ const Modal = (($) => { - - /** * ------------------------------------------------------------------------ * Constants @@ -73,7 +70,6 @@ const Modal = (($) => { NAVBAR_TOGGLER : '.navbar-toggler' } - /** * ------------------------------------------------------------------------ * Class Definition @@ -81,7 +77,6 @@ const Modal = (($) => { */ class Modal { - constructor(element, config) { this._config = this._getConfig(config) this._element = element @@ -94,8 +89,7 @@ const Modal = (($) => { this._scrollbarWidth = 0 } - - // getters + // Getters static get VERSION() { return VERSION @@ -105,8 +99,7 @@ const Modal = (($) => { return Default } - - // public + // Public toggle(relatedTarget) { return this._isShown ? this.hide() : this.show(relatedTarget) @@ -196,7 +189,6 @@ const Modal = (($) => { $(this._dialog).off(Event.MOUSEDOWN_DISMISS) if (transition) { - $(this._element) .one(Util.TRANSITION_END, (event) => this._hideModal(event)) .emulateTransitionEnd(TRANSITION_DURATION) @@ -224,7 +216,7 @@ const Modal = (($) => { this._adjustDialog() } - // private + // Private _getConfig(config) { config = { @@ -241,7 +233,7 @@ const Modal = (($) => { if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { - // don't move modals dom position + // Don't move modal's DOM position document.body.appendChild(this._element) } @@ -282,11 +274,11 @@ const Modal = (($) => { _enforceFocus() { $(document) - .off(Event.FOCUSIN) // guard against infinite focus loop + .off(Event.FOCUSIN) // Guard against infinite focus loop .on(Event.FOCUSIN, (event) => { if (document !== event.target && this._element !== event.target && - !$(this._element).has(event.target).length) { + $(this._element).has(event.target).length === 0) { this._element.focus() } }) @@ -300,7 +292,6 @@ const Modal = (($) => { this.hide() } }) - } else if (!this._isShown) { $(this._element).off(Event.KEYDOWN_DISMISS) } @@ -334,8 +325,8 @@ const Modal = (($) => { } _showBackdrop(callback) { - const animate = $(this._element).hasClass(ClassName.FADE) ? - ClassName.FADE : '' + const animate = $(this._element).hasClass(ClassName.FADE) + ? ClassName.FADE : '' if (this._isShown && this._config.backdrop) { const doAnimate = Util.supportsTransitionEnd() && animate @@ -382,7 +373,6 @@ const Modal = (($) => { $(this._backdrop) .one(Util.TRANSITION_END, callback) .emulateTransitionEnd(BACKDROP_TRANSITION_DURATION) - } else if (!this._isShown && this._backdrop) { $(this._backdrop).removeClass(ClassName.SHOW) @@ -401,13 +391,11 @@ const Modal = (($) => { } else { callbackRemove() } - } else if (callback) { callback() } } - // ---------------------------------------------------------------------- // the following methods are used to handle overflowing modals // todo (fat): these should probably be refactored out of modal.js @@ -503,12 +491,11 @@ const Modal = (($) => { return scrollbarWidth } - - // static + // Static static _jQueryInterface(config, relatedTarget) { return this.each(function () { - let data = $(this).data(DATA_KEY) + let data = $(this).data(DATA_KEY) const _config = { ...Modal.Default, ...$(this).data(), @@ -522,7 +509,7 @@ const Modal = (($) => { if (typeof config === 'string') { if (typeof data[config] === 'undefined') { - throw new Error(`No method named "${config}"`) + throw new TypeError(`No method named "${config}"`) } data[config](relatedTarget) } else if (_config.show) { @@ -530,10 +517,8 @@ const Modal = (($) => { } }) } - } - /** * ------------------------------------------------------------------------ * Data Api implementation @@ -548,8 +533,8 @@ const Modal = (($) => { target = $(selector)[0] } - const config = $(target).data(DATA_KEY) ? - 'toggle' : { + const config = $(target).data(DATA_KEY) + ? 'toggle' : { ...$(target).data(), ...$(this).data() } @@ -560,7 +545,7 @@ const Modal = (($) => { const $target = $(target).one(Event.SHOW, (showEvent) => { if (showEvent.isDefaultPrevented()) { - // only register focus restorer if modal will actually get shown + // Only register focus restorer if modal will actually get shown return } @@ -574,22 +559,20 @@ const Modal = (($) => { Modal._jQueryInterface.call($(target), config, this) }) - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ - $.fn[NAME] = Modal._jQueryInterface + $.fn[NAME] = Modal._jQueryInterface $.fn[NAME].Constructor = Modal - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return Modal._jQueryInterface } return Modal - })($) export default Modal diff --git a/js/src/popover.js b/js/src/popover.js index f557e8bcd2..02d6827329 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -1,7 +1,6 @@ import $ from 'jquery' import Tooltip from './tooltip' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta.3): popover.js @@ -10,8 +9,6 @@ import Tooltip from './tooltip' */ const Popover = (($) => { - - /** * ------------------------------------------------------------------------ * Constants @@ -31,10 +28,10 @@ const Popover = (($) => { placement : 'right', trigger : 'click', content : '', - template : '
Holy guacamole! Best check yo self, you\'re not looking too good.
' - + 'Holy guacamole! Best check yo self, you\'re not looking too good.
' + + 'Holy guacamole! Best check yo self, you\'re not looking too good.
' - + 'Holy guacamole! Best check yo self, you\'re not looking too good.
' + + '