From 35f80bb12e4e71fd777ee60ffa43711d8f84b1a6 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 10 Aug 2017 20:56:35 -0700 Subject: bump to beta --- js/src/alert.js | 4 ++-- js/src/button.js | 4 ++-- js/src/carousel.js | 4 ++-- js/src/collapse.js | 4 ++-- js/src/dropdown.js | 4 ++-- js/src/modal.js | 4 ++-- js/src/popover.js | 4 ++-- js/src/scrollspy.js | 4 ++-- js/src/tab.js | 4 ++-- js/src/tooltip.js | 4 ++-- js/src/util.js | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) (limited to 'js/src') diff --git a/js/src/alert.js b/js/src/alert.js index b30d0d3a0..b6b9336af 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): alert.js + * Bootstrap (v4.0.0-beta): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Alert = (($) => { */ const NAME = 'alert' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.alert' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/button.js b/js/src/button.js index 722fd489d..a8a72ef56 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): button.js + * Bootstrap (v4.0.0-beta): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -15,7 +15,7 @@ const Button = (($) => { */ const NAME = 'button' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.button' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/carousel.js b/js/src/carousel.js index 5993de256..a5d5f143a 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): carousel.js + * Bootstrap (v4.0.0-beta): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Carousel = (($) => { */ const NAME = 'carousel' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.carousel' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/collapse.js b/js/src/collapse.js index 78ed32906..2f00b98cb 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): collapse.js + * Bootstrap (v4.0.0-beta): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Collapse = (($) => { */ const NAME = 'collapse' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.collapse' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 234d23447..5e792a527 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -5,7 +5,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): dropdown.js + * Bootstrap (v4.0.0-beta): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ const Dropdown = (($) => { */ const NAME = 'dropdown' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.dropdown' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/modal.js b/js/src/modal.js index 02d463945..9f17fafc8 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): modal.js + * Bootstrap (v4.0.0-beta): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Modal = (($) => { */ const NAME = 'modal' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.modal' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/popover.js b/js/src/popover.js index 5c2b65b86..0e8953f77 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -3,7 +3,7 @@ import Tooltip from './tooltip' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): popover.js + * Bootstrap (v4.0.0-beta): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Popover = (($) => { */ const NAME = 'popover' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.popover' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 7ea9f2483..b70b7e477 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): scrollspy.js + * Bootstrap (v4.0.0-beta): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const ScrollSpy = (($) => { */ const NAME = 'scrollspy' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.scrollspy' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/tab.js b/js/src/tab.js index c7bc520df..1613bbb7d 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): tab.js + * Bootstrap (v4.0.0-beta): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Tab = (($) => { */ const NAME = 'tab' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.tab' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/tooltip.js b/js/src/tooltip.js index c7c7b9f9d..2060cebbb 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -5,7 +5,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): tooltip.js + * Bootstrap (v4.0.0-beta): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ const Tooltip = (($) => { */ const NAME = 'tooltip' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.tooltip' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] diff --git a/js/src/util.js b/js/src/util.js index 3c0d02251..387c7d2ed 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): util.js + * Bootstrap (v4.0.0-beta): util.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From b55fa5579b409be76f551cbb3c1e46e1ad71bdfd Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 14 Jul 2017 17:49:30 +0300 Subject: tabs: make the `active` selector more restrictive again. When one uses say a carousel inside a tab, the `.active` selector previously matches the carousel ones too leading to broken tabs. It's not the perfect solution but should the job for now. --- js/src/tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/tab.js b/js/src/tab.js index 1613bbb7d..4fd69c507 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -44,7 +44,7 @@ const Tab = (($) => { const Selector = { DROPDOWN : '.dropdown', NAV_LIST_GROUP : '.nav, .list-group', - ACTIVE : '.active', + ACTIVE : '> .nav-item > .active, > .active', DATA_TOGGLE : '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]', DROPDOWN_TOGGLE : '.dropdown-toggle', DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active' -- cgit v1.2.3 From 640c13062ce80b0b94aef9444050d4d3820fb2d8 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Sun, 16 Jul 2017 16:04:37 +0200 Subject: When we show our tabs element use children to be more restrictive --- js/src/tab.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/tab.js b/js/src/tab.js index 4fd69c507..5e5a83118 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -44,7 +44,7 @@ const Tab = (($) => { const Selector = { DROPDOWN : '.dropdown', NAV_LIST_GROUP : '.nav, .list-group', - ACTIVE : '> .nav-item > .active, > .active', + ACTIVE : '.active', DATA_TOGGLE : '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]', DROPDOWN_TOGGLE : '.dropdown-toggle', DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active' @@ -148,7 +148,8 @@ const Tab = (($) => { // private _activate(element, container, callback) { - const active = $(container).find(Selector.ACTIVE)[0] + const activeElements = callback ? $(container).children(Selector.ACTIVE) : $(container).find(Selector.ACTIVE) + const active = activeElements[0] const isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE)) -- cgit v1.2.3 From 2eb1e687bd74d147145000b3971821cc890d7652 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 18 Jul 2017 14:22:39 +0200 Subject: Improve previous selector for nested tabs --- js/src/tab.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/tab.js b/js/src/tab.js index 5e5a83118..4c3091495 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -45,6 +45,7 @@ const Tab = (($) => { DROPDOWN : '.dropdown', NAV_LIST_GROUP : '.nav, .list-group', ACTIVE : '.active', + ACTIVE_UL : '> li > .active', DATA_TOGGLE : '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]', DROPDOWN_TOGGLE : '.dropdown-toggle', DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active' @@ -87,7 +88,8 @@ const Tab = (($) => { const selector = Util.getSelectorFromElement(this._element) if (listElement) { - previous = $.makeArray($(listElement).find(Selector.ACTIVE)) + const itemSelector = listElement.nodeName === 'UL' ? Selector.ACTIVE_UL : Selector.ACTIVE + previous = $.makeArray($(listElement).find(itemSelector)) previous = previous[previous.length - 1] } @@ -148,7 +150,13 @@ const Tab = (($) => { // private _activate(element, container, callback) { - const activeElements = callback ? $(container).children(Selector.ACTIVE) : $(container).find(Selector.ACTIVE) + let activeElements + if (container.nodeName === 'UL') { + activeElements = $(container).find(Selector.ACTIVE_UL) + } else { + activeElements = $(container).children(Selector.ACTIVE) + } + const active = activeElements[0] const isTransitioning = callback && Util.supportsTransitionEnd() -- cgit v1.2.3 From 58b54b6c15543dce3aca90e202037fa3b194f72e Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 17 Aug 2017 17:44:09 +0200 Subject: Carousel - do not call next when the carousel or the parent isn't visible --- js/src/carousel.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index a5d5f143a..27a8f7d3b 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -131,7 +131,9 @@ const Carousel = (($) => { nextWhenVisible() { // Don't call next when the page isn't visible - if (!document.hidden) { + // or the carousel or it's parent isn't visible + if (!document.hidden && + ($(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden')) { this.next() } } -- cgit v1.2.3 From 74d96392d2370c5e0f54380ddb5c7a09d6c13ac7 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 18 Aug 2017 16:55:59 +0300 Subject: Update devDependencies and fix a typo in comment. (#23534) --- js/src/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index 27a8f7d3b..6bcf470f9 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -131,7 +131,7 @@ const Carousel = (($) => { nextWhenVisible() { // Don't call next when the page isn't visible - // or the carousel or it's parent isn't visible + // or the carousel or its parent isn't visible if (!document.hidden && ($(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden')) { this.next() -- cgit v1.2.3 From ef8c77d8dcebd13559a141e419d003c2d10cc5f3 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 27 Jul 2017 13:39:55 +0300 Subject: Tweak ESLint rules. --- js/src/carousel.js | 2 +- js/src/collapse.js | 2 +- js/src/dropdown.js | 4 ++-- js/src/modal.js | 2 +- js/src/popover.js | 2 +- js/src/scrollspy.js | 5 +++-- js/src/tab.js | 2 +- js/src/tooltip.js | 2 +- js/src/util.js | 6 +++--- 9 files changed, 14 insertions(+), 13 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index 6bcf470f9..873660519 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -443,7 +443,7 @@ const Carousel = (($) => { if (typeof config === 'number') { data.to(config) } else if (typeof action === 'string') { - if (data[action] === undefined) { + if (typeof data[action] === 'undefined') { throw new Error(`No method named "${action}"`) } data[action]() diff --git a/js/src/collapse.js b/js/src/collapse.js index 2f00b98cb..718630bd3 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -343,7 +343,7 @@ const Collapse = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 5e792a527..e1c48ac6e 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -204,7 +204,7 @@ const Dropdown = (($) => { _getConfig(config) { const elementData = $(this._element).data() - if (elementData.placement !== undefined) { + if (typeof elementData.placement !== 'undefined') { elementData.placement = AttachmentMap[elementData.placement.toUpperCase()] } @@ -287,7 +287,7 @@ const Dropdown = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/modal.js b/js/src/modal.js index 9f17fafc8..d21a137fb 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -507,7 +507,7 @@ const Modal = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config](relatedTarget) diff --git a/js/src/popover.js b/js/src/popover.js index 0e8953f77..7639e3e20 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -162,7 +162,7 @@ const Popover = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index b70b7e477..588f65298 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -231,7 +231,7 @@ const ScrollSpy = (($) => { for (let i = this._offsets.length; i--;) { const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] - && (this._offsets[i + 1] === undefined || + && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]) if (isActiveTarget) { @@ -246,6 +246,7 @@ const ScrollSpy = (($) => { this._clear() let queries = this._selector.split(',') + // eslint-disable-next-line arrow-body-style queries = queries.map((selector) => { return `${selector}[data-target="${target}"],` + `${selector}[href="${target}"]` @@ -287,7 +288,7 @@ const ScrollSpy = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/tab.js b/js/src/tab.js index 4c3091495..c32cd3776 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -238,7 +238,7 @@ const Tab = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2060cebbb..721f04481 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -698,7 +698,7 @@ const Tooltip = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/util.js b/js/src/util.js index 387c7d2ed..69fb8283c 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -42,7 +42,7 @@ const Util = (($) => { if ($(event.target).is(this)) { return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params } - return undefined + return undefined // eslint-disable-line no-undefined } } } @@ -55,7 +55,7 @@ const Util = (($) => { const el = document.createElement('bootstrap') for (const name in TransitionEndEvent) { - if (el.style[name] !== undefined) { + if (typeof el.style[name] !== 'undefined') { return { end: TransitionEndEvent[name] } @@ -138,7 +138,7 @@ const Util = (($) => { typeCheckConfig(componentName, config, configTypes) { for (const property in configTypes) { - if (configTypes.hasOwnProperty(property)) { + if (Object.prototype.hasOwnProperty.call(configTypes, property)) { const expectedTypes = configTypes[property] const value = config[property] const valueType = value && isElement(value) ? -- cgit v1.2.3 From 6063b0dc659e7ba3a83cfc9502ad7872f8201a32 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 27 Jul 2017 12:58:22 +0200 Subject: Enable the `no-return-assign` rule. --- js/src/popover.js | 3 ++- js/src/tooltip.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/popover.js b/js/src/popover.js index 7639e3e20..f5820ecbe 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -114,7 +114,8 @@ const Popover = (($) => { } getTipElement() { - return this.tip = this.tip || $(this.config.template)[0] + this.tip = this.tip || $(this.config.template)[0] + return this.tip } setContent() { diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 721f04481..7dfe9dfc0 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -415,7 +415,8 @@ const Tooltip = (($) => { } getTipElement() { - return this.tip = this.tip || $(this.config.template)[0] + this.tip = this.tip || $(this.config.template)[0] + return this.tip } setContent() { -- cgit v1.2.3 From 4571ab0e57a5d2ff251b8c174ab0f693c5892dce Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 24 Aug 2017 09:40:11 +0200 Subject: Fix toggle for Tooltips/Popover which was called even if the Tooltip/Popover was disabled --- js/src/tooltip.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 7dfe9dfc0..37573cf49 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -184,6 +184,10 @@ const Tooltip = (($) => { } toggle(event) { + if (!this._isEnabled) { + return + } + if (event) { const dataKey = this.constructor.DATA_KEY let context = $(event.currentTarget).data(dataKey) @@ -234,8 +238,8 @@ const Tooltip = (($) => { if (this._popper !== null) { this._popper.destroy() } - this._popper = null + this._popper = null this.element = null this.config = null this.tip = null @@ -706,7 +710,6 @@ const Tooltip = (($) => { } }) } - } -- cgit v1.2.3 From 5a90b4aa3e102e387839a39fbf0ab1444eebbc76 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 25 Aug 2017 10:14:18 +0200 Subject: Collapse - preventDefault only on elements not inside the collapsible element --- js/src/collapse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/collapse.js b/js/src/collapse.js index 718630bd3..7d1ba4c54 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -361,7 +361,8 @@ const Collapse = (($) => { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - if (!/input|textarea/i.test(event.target.tagName)) { + // preventDefault only for elements (which change the URL) not inside the collapsible element + if (event.target.tagName === 'A' && !$.contains(this, event.target)) { event.preventDefault() } -- cgit v1.2.3 From ba6a6f13691000ffaf22ef8e731513737659447f Mon Sep 17 00:00:00 2001 From: David Bailey Date: Fri, 25 Aug 2017 22:01:41 +0100 Subject: Fix sticky margin when a modal is opened (#23669) * Adjust margin for sticky elements on modal Previously white space was visible to the right of sticky elements due to right padding being added to the body. This fixes #23661. * Add unit tests for margin of sticky elements on modal --- js/src/modal.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index d21a137fb..ab73230c8 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -68,6 +68,7 @@ const Modal = (($) => { DATA_TOGGLE : '[data-toggle="modal"]', DATA_DISMISS : '[data-dismiss="modal"]', FIXED_CONTENT : '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top', + STICKY_CONTENT : '.sticky-top', NAVBAR_TOGGLER : '.navbar-toggler' } @@ -441,6 +442,13 @@ const Modal = (($) => { $(element).data('padding-right', actualPadding).css('padding-right', `${parseFloat(calculatedPadding) + this._scrollbarWidth}px`) }) + // Adjust sticky content margin + $(Selector.STICKY_CONTENT).each((index, element) => { + const actualMargin = $(element)[0].style.marginRight + const calculatedMargin = $(element).css('margin-right') + $(element).data('margin-right', actualMargin).css('margin-right', `${parseFloat(calculatedMargin) - this._scrollbarWidth}px`) + }) + // Adjust navbar-toggler margin $(Selector.NAVBAR_TOGGLER).each((index, element) => { const actualMargin = $(element)[0].style.marginRight @@ -464,8 +472,8 @@ const Modal = (($) => { } }) - // Restore navbar-toggler margin - $(Selector.NAVBAR_TOGGLER).each((index, element) => { + // Restore sticky content and navbar-toggler margin + $(`${Selector.STICKY_CONTENT}, ${Selector.NAVBAR_TOGGLER}`).each((index, element) => { const margin = $(element).data('margin-right') if (typeof margin !== 'undefined') { $(element).css('margin-right', margin).removeData('margin-right') -- cgit v1.2.3 From bcad4bcb5f5a9ef079b2883a48a698b35261e083 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 25 Aug 2017 21:54:49 +0200 Subject: Fix XSS in data-target --- js/src/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/util.js b/js/src/util.js index 69fb8283c..cd3f1fb6a 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -117,7 +117,7 @@ const Util = (($) => { } try { - const $selector = $(selector) + const $selector = $(document).find(selector) return $selector.length > 0 ? selector : null } catch (error) { return null -- cgit v1.2.3 From a4fff7c38397fa8fb59891cc94807be020ac37ec Mon Sep 17 00:00:00 2001 From: David Bailey Date: Mon, 28 Aug 2017 18:35:47 +0100 Subject: Fix unwanted body padding when a modal opens Prevents the test from failing --- js/src/modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index ab73230c8..a88c14444 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -426,7 +426,7 @@ const Modal = (($) => { } _checkScrollbar() { - this._isBodyOverflowing = document.body.clientWidth < window.innerWidth + this._isBodyOverflowing = document.body.offsetWidth < window.innerWidth this._scrollbarWidth = this._getScrollbarWidth() } -- cgit v1.2.3 From 2725acc9e576059e2dbb3e4722dd5beef84e9215 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Mon, 28 Aug 2017 18:44:56 +0100 Subject: Use jQuery outerWidth instead of offsetWidth --- js/src/modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index a88c14444..c8c7e3d21 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -426,7 +426,7 @@ const Modal = (($) => { } _checkScrollbar() { - this._isBodyOverflowing = document.body.offsetWidth < window.innerWidth + this._isBodyOverflowing = $('body').outerWidth(true) < window.innerWidth this._scrollbarWidth = this._getScrollbarWidth() } -- cgit v1.2.3 From 3f2a8db4711e420b48b7a5b4c36f158a1b9eabab Mon Sep 17 00:00:00 2001 From: David Bailey Date: Mon, 28 Aug 2017 18:55:45 +0100 Subject: Use getBoundingClientRect instead of jQuery --- js/src/modal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index c8c7e3d21..0306b4e87 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -426,7 +426,8 @@ const Modal = (($) => { } _checkScrollbar() { - this._isBodyOverflowing = $('body').outerWidth(true) < window.innerWidth + const rect = document.body.getBoundingClientRect() + this._isBodyOverflowing = rect.left + rect.right < window.innerWidth this._scrollbarWidth = this._getScrollbarWidth() } -- cgit v1.2.3 From cbaf7a7b79c78ec7d877f348d12102acde6adfa0 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 29 Aug 2017 15:42:58 +0100 Subject: Fix failing test _adjustDialog should be called when the modal is first displayed to prevent it jumping position when the viewport is resized --- js/src/modal.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index ab73230c8..5892ed045 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -135,6 +135,8 @@ const Modal = (($) => { this._checkScrollbar() this._setScrollbar() + this._adjustDialog() + $(document.body).addClass(ClassName.OPEN) this._setEscapeEvent() -- cgit v1.2.3 From 9936bf59444c402b653f28449529eab83794e911 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 29 Aug 2017 21:16:00 +0200 Subject: Create a bundled release of Bootstrap with Popper.js inside --- js/src/alert.js | 3 ++- js/src/button.js | 3 ++- js/src/carousel.js | 3 ++- js/src/collapse.js | 3 ++- js/src/dropdown.js | 8 ++++---- js/src/index.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ js/src/modal.js | 3 ++- js/src/popover.js | 3 ++- js/src/scrollspy.js | 3 ++- js/src/tab.js | 3 ++- js/src/tooltip.js | 8 ++++---- js/src/util.js | 4 +++- 12 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 js/src/index.js (limited to 'js/src') diff --git a/js/src/alert.js b/js/src/alert.js index b6b9336af..9fcf088b1 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Alert = (($) => { +const Alert = (() => { /** diff --git a/js/src/button.js b/js/src/button.js index a8a72ef56..a121b8e13 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -1,3 +1,4 @@ +import $ from 'jquery' /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta): button.js @@ -5,7 +6,7 @@ * -------------------------------------------------------------------------- */ -const Button = (($) => { +const Button = (() => { /** diff --git a/js/src/carousel.js b/js/src/carousel.js index 873660519..a5ad02541 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Carousel = (($) => { +const Carousel = (() => { /** diff --git a/js/src/collapse.js b/js/src/collapse.js index 7d1ba4c54..acc959d40 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Collapse = (($) => { +const Collapse = (() => { /** diff --git a/js/src/dropdown.js b/js/src/dropdown.js index e1c48ac6e..adb54f0f2 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -1,5 +1,5 @@ -/* global Popper */ - +import $ from 'jquery' +import Popper from 'popper.js' import Util from './util' @@ -10,7 +10,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Dropdown = (($) => { +const Dropdown = (() => { /** * Check for Popper dependency @@ -445,6 +445,6 @@ const Dropdown = (($) => { return Dropdown -})(jQuery) +})(jQuery, Popper) export default Dropdown diff --git a/js/src/index.js b/js/src/index.js new file mode 100644 index 000000000..a3858dd24 --- /dev/null +++ b/js/src/index.js @@ -0,0 +1,46 @@ +import $ from 'jquery' +import Alert from './alert' +import Button from './button' +import Carousel from './carousel' +import Collapse from './collapse' +import Dropdown from './dropdown' +import Modal from './modal' +import Popover from './popover' +import Scrollspy from './scrollspy' +import Tab from './tab' +import Tooltip from './tooltip' +import Util from './util' + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): index.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +if (typeof jQuery === 'undefined') { + throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') +} + +(() => { + const version = $.fn.jquery.split(' ')[0].split('.') + const min = 3 + const max = 4 + if (version[0] < min || version[0] >= max) { + throw new Error('Bootstrap\'s JavaScript requires at least jQuery v3.0.0 but less than v4.0.0') + } +})(jQuery) + +export { + Util, + Alert, + Button, + Carousel, + Collapse, + Dropdown, + Modal, + Popover, + Scrollspy, + Tab, + Tooltip +} diff --git a/js/src/modal.js b/js/src/modal.js index ab73230c8..2ff93342d 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Modal = (($) => { +const Modal = (() => { /** diff --git a/js/src/popover.js b/js/src/popover.js index f5820ecbe..aeccdf750 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Tooltip from './tooltip' @@ -8,7 +9,7 @@ import Tooltip from './tooltip' * -------------------------------------------------------------------------- */ -const Popover = (($) => { +const Popover = (() => { /** diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 588f65298..70067c0b3 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const ScrollSpy = (($) => { +const ScrollSpy = (() => { /** diff --git a/js/src/tab.js b/js/src/tab.js index c32cd3776..18af4e7e2 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Tab = (($) => { +const Tab = (() => { /** diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 37573cf49..5dc28ab7e 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,5 +1,5 @@ -/* global Popper */ - +import $ from 'jquery' +import Popper from 'popper.js' import Util from './util' @@ -10,7 +10,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Tooltip = (($) => { +const Tooltip = (() => { /** * Check for Popper dependency @@ -728,6 +728,6 @@ const Tooltip = (($) => { return Tooltip -})(jQuery) +})(jQuery, Popper) export default Tooltip diff --git a/js/src/util.js b/js/src/util.js index cd3f1fb6a..b18d0f776 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -1,3 +1,5 @@ +import $ from 'jquery' + /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta): util.js @@ -5,7 +7,7 @@ * -------------------------------------------------------------------------- */ -const Util = (($) => { +const Util = (() => { /** -- cgit v1.2.3 From a4667be152a3a4fed4e42f2a9efbf831bb5946b6 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 31 Aug 2017 19:19:10 +0200 Subject: Regroup our jQuery check in the same IIFE --- js/src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/src') diff --git a/js/src/index.js b/js/src/index.js index a3858dd24..84a27880e 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -18,11 +18,11 @@ import Util from './util' * -------------------------------------------------------------------------- */ -if (typeof jQuery === 'undefined') { - throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') -} - (() => { + if (typeof jQuery === 'undefined') { + throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') + } + const version = $.fn.jquery.split(' ')[0].split('.') const min = 3 const max = 4 -- cgit v1.2.3 From b822b5a17f87c62000ec3a058e3f2ccca8a10d3e Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 7 Sep 2017 12:47:43 +0200 Subject: Remove placement attribute from our Dropdown plugin --- js/src/dropdown.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'js/src') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index adb54f0f2..f76f84ef0 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -75,13 +75,11 @@ const Dropdown = (() => { } const Default = { - placement : AttachmentMap.BOTTOM, offset : 0, flip : true } const DefaultType = { - placement : 'string', offset : '(number|string)', flip : 'boolean' } @@ -203,11 +201,6 @@ const Dropdown = (() => { } _getConfig(config) { - const elementData = $(this._element).data() - if (typeof elementData.placement !== 'undefined') { - elementData.placement = AttachmentMap[elementData.placement.toUpperCase()] - } - config = $.extend( {}, this.constructor.Default, @@ -234,10 +227,10 @@ const Dropdown = (() => { _getPlacement() { const $parentDropdown = $(this._element).parent() - let placement = this._config.placement + let placement = AttachmentMap.BOTTOM // Handle dropup - if ($parentDropdown.hasClass(ClassName.DROPUP) || this._config.placement === AttachmentMap.TOP) { + if ($parentDropdown.hasClass(ClassName.DROPUP)) { placement = AttachmentMap.TOP if ($(this._menu).hasClass(ClassName.MENURIGHT)) { placement = AttachmentMap.TOPEND -- cgit v1.2.3 From 45276521778c9843c3d308f7fcda4168a75f4825 Mon Sep 17 00:00:00 2001 From: Patrick Yeo Date: Fri, 8 Sep 2017 14:53:15 -0700 Subject: Collapse.js preventDefault if `[data-toggle="collapse"]` is an anchor tag --- js/src/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/collapse.js b/js/src/collapse.js index acc959d40..bf9c990ec 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -363,7 +363,7 @@ const Collapse = (() => { $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { // preventDefault only for elements (which change the URL) not inside the collapsible element - if (event.target.tagName === 'A' && !$.contains(this, event.target)) { + if (event.currentTarget.tagName === 'A') { event.preventDefault() } -- cgit v1.2.3 From d5890cb82f4dcd2b5b8e2e6d4d7bebd1026e2228 Mon Sep 17 00:00:00 2001 From: vsn4ik Date: Mon, 11 Sep 2017 22:44:42 +0300 Subject: Remove not necessary condition in tooltip.js --- js/src/tooltip.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 5dc28ab7e..ca7e52b14 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -622,18 +622,18 @@ const Tooltip = (() => { config ) - if (config.delay && typeof config.delay === 'number') { + if (typeof config.delay === 'number') { config.delay = { show : config.delay, hide : config.delay } } - if (config.title && typeof config.title === 'number') { + if (typeof config.title === 'number') { config.title = config.title.toString() } - if (config.content && typeof config.content === 'number') { + if (typeof config.content === 'number') { config.content = config.content.toString() } -- cgit v1.2.3 From 6c70c70f637267ca109f44ff63f564892ece42bf Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Sun, 17 Sep 2017 04:30:37 -0300 Subject: fix(scrollspy): Spying on nested navs fails to activate for .nav-link's inside nav-item's (#23967) * fix(scrollspy): Handle nested navs when nav-link inside nav-item * [scrolspy] Find only child .nav-link's inside .nav-item * [scrollspyt] Add tests for nested navs with nav-link inside nav-item * fix troy-o's in test --- js/src/scrollspy.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/src') diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 70067c0b3..e8f0d3101 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -54,6 +54,7 @@ const ScrollSpy = (() => { ACTIVE : '.active', NAV_LIST_GROUP : '.nav, .list-group', NAV_LINKS : '.nav-link', + NAV_ITEMS : '.nav-item', LIST_ITEMS : '.list-group-item', DROPDOWN : '.dropdown', DROPDOWN_ITEMS : '.dropdown-item', @@ -264,6 +265,8 @@ const ScrollSpy = (() => { // Set triggered links parents as active // With both
    and