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