From 045888fa3887f5e65658499da11c8ad737222759 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Fri, 6 Jan 2017 08:38:04 -0800 Subject: version bump --- js/src/collapse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index ad8815993..28c4493cc 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.5): collapse.js + * Bootstrap (v4.0.0-alpha.6): 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.5' + const VERSION = '4.0.0-alpha.6' const DATA_KEY = 'bs.collapse' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' -- cgit v1.2.3 From 099486f294e79bfe1f2c6b431ee4696237f616cd Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 7 Mar 2017 10:46:08 +0100 Subject: Detach accordions from .card --- js/src/collapse.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 28c4493cc..e2c9efe11 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -57,7 +57,8 @@ const Collapse = (($) => { const Selector = { ACTIVES : '.card > .show, .card > .collapsing', - DATA_TOGGLE : '[data-toggle="collapse"]' + DATA_TOGGLE : '[data-toggle="collapse"]', + DATA_CHILDREN : 'data-children' } @@ -84,6 +85,14 @@ const Collapse = (($) => { this._addAriaAndCollapsedClass(this._element, this._triggerArray) } + this._selectorActives = Selector.ACTIVES + if (this._parent) { + const childrenSelector = this._parent.hasAttribute(Selector.DATA_CHILDREN) ? this._parent.getAttribute(Selector.DATA_CHILDREN) : null + if (childrenSelector !== null) { + this._selectorActives = childrenSelector + ' > .show, ' + childrenSelector + ' > .collapsing' + } + } + if (this._config.toggle) { this.toggle() } @@ -124,7 +133,7 @@ const Collapse = (($) => { let activesData if (this._parent) { - actives = $.makeArray($(this._parent).find(Selector.ACTIVES)) + actives = $.makeArray($(this._parent).find(this._selectorActives)) if (!actives.length) { actives = null } -- cgit v1.2.3 From fa1504e6f68974114e3ab58b8b18a601bc973103 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 8 Mar 2017 11:15:58 +0100 Subject: Fix code style --- js/src/collapse.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index e2c9efe11..0776519ff 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -78,7 +78,6 @@ const Collapse = (($) => { `[data-toggle="collapse"][href="#${element.id}"],` + `[data-toggle="collapse"][data-target="#${element.id}"]` )) - this._parent = this._config.parent ? this._getParent() : null if (!this._config.parent) { @@ -89,7 +88,7 @@ const Collapse = (($) => { if (this._parent) { const childrenSelector = this._parent.hasAttribute(Selector.DATA_CHILDREN) ? this._parent.getAttribute(Selector.DATA_CHILDREN) : null if (childrenSelector !== null) { - this._selectorActives = childrenSelector + ' > .show, ' + childrenSelector + ' > .collapsing' + this._selectorActives = `${childrenSelector} > .show, ${childrenSelector} > .collapsing` } } -- cgit v1.2.3 From 275821bbb081890ffe232d50d4778eb15bdb1d7b Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Sat, 18 Mar 2017 21:24:54 -0400 Subject: HTMLElement.offset* by getBoundingClientRect() (#21788) * Replace element.offet* by getBoundingClientRect() * Use variable to store BoundingClientRect * Fix cc issue... --- js/src/collapse.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 28c4493cc..ed3c064b1 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -211,10 +211,8 @@ const Collapse = (($) => { } const dimension = this._getDimension() - const offsetDimension = dimension === Dimension.WIDTH ? - 'offsetWidth' : 'offsetHeight' - this._element.style[dimension] = `${this._element[offsetDimension]}px` + this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px` Util.reflow(this._element) -- cgit v1.2.3 From 24924c23b24c1b196c42166ebe9a17d31f0ee720 Mon Sep 17 00:00:00 2001 From: Johann Date: Mon, 27 Mar 2017 10:08:39 +0200 Subject: Collapse - do not prevent event for input and textarea --- js/src/collapse.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 13c44502c..6f09fcadd 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -363,7 +363,9 @@ const Collapse = (($) => { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - event.preventDefault() + if (/input|textarea/i.test(event.target.tagName)) { + event.preventDefault() + } const target = Collapse._getTargetFromElement(this) const data = $(target).data(DATA_KEY) -- cgit v1.2.3 From 48c5efa4c3c439d8720b8475ec3e372c6974a12a Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Tue, 28 Mar 2017 17:43:16 -0400 Subject: Fix JS components console error "Error: is transitioning" --- js/src/collapse.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 6f09fcadd..dc2e2a67d 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -120,11 +120,8 @@ const Collapse = (($) => { } show() { - if (this._isTransitioning) { - throw new Error('Collapse is transitioning') - } - - if ($(this._element).hasClass(ClassName.SHOW)) { + if (this._isTransitioning || + $(this._element).hasClass(ClassName.SHOW)) { return } @@ -204,11 +201,8 @@ const Collapse = (($) => { } hide() { - if (this._isTransitioning) { - throw new Error('Collapse is transitioning') - } - - if (!$(this._element).hasClass(ClassName.SHOW)) { + if (this._isTransitioning || + !$(this._element).hasClass(ClassName.SHOW)) { return } -- cgit v1.2.3 From fb42d6e0435bb101c0505090055e8034cb101dc4 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 29 Mar 2017 00:10:27 +0200 Subject: Collapse - Fix check to not prevent event for input and textarea --- js/src/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index dc2e2a67d..88428310d 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -357,7 +357,7 @@ const Collapse = (($) => { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - if (/input|textarea/i.test(event.target.tagName)) { + if (!/input|textarea/i.test(event.target.tagName)) { event.preventDefault() } -- cgit v1.2.3 From 18e8704221791e70d0bf4ac9ff45d4e897a02e63 Mon Sep 17 00:00:00 2001 From: "Patrick H. Lauke" Date: Mon, 10 Apr 2017 14:51:22 +0100 Subject: Fix collapse.js aria-expanded behavior * Remove aria-expanded from collapse.js target element aria-expanded="true"/aria-expanded="false" only applies to the trigger, not the element that is being expanded/collapsed. * Tweak collapse.js accessibility section ...to make it clearer that the aria-expanded attribute always just goes on the control. * Fix collapse.js unit tests - reword some of the text to make it clear we're checking behavior of trigger/control - move incorrect aria-expanded out of the
s and to the actual trigger/control s - fix incorrect test assertion text output false -> true --- js/src/collapse.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 88428310d..dec272297 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -162,7 +162,6 @@ const Collapse = (($) => { .addClass(ClassName.COLLAPSING) this._element.style[dimension] = 0 - this._element.setAttribute('aria-expanded', true) if (this._triggerArray.length) { $(this._triggerArray) @@ -223,8 +222,6 @@ const Collapse = (($) => { .removeClass(ClassName.COLLAPSE) .removeClass(ClassName.SHOW) - this._element.setAttribute('aria-expanded', false) - if (this._triggerArray.length) { $(this._triggerArray) .addClass(ClassName.COLLAPSED) @@ -300,7 +297,6 @@ const Collapse = (($) => { _addAriaAndCollapsedClass(element, triggerArray) { if (element) { const isOpen = $(element).hasClass(ClassName.SHOW) - element.setAttribute('aria-expanded', isOpen) if (triggerArray.length) { $(triggerArray) -- cgit v1.2.3 From ab39defe74914109df164c823af927de68320d55 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Tue, 25 Apr 2017 03:32:14 -0400 Subject: Detach accordion from card without requiring 'data-children' --- js/src/collapse.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index dec272297..bf1c738f5 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -56,9 +56,8 @@ const Collapse = (($) => { } const Selector = { - ACTIVES : '.card > .show, .card > .collapsing', - DATA_TOGGLE : '[data-toggle="collapse"]', - DATA_CHILDREN : 'data-children' + ACTIVES : '.show, .collapsing', + DATA_TOGGLE : '[data-toggle="collapse"]' } @@ -78,20 +77,13 @@ const Collapse = (($) => { `[data-toggle="collapse"][href="#${element.id}"],` + `[data-toggle="collapse"][data-target="#${element.id}"]` )) + this._parent = this._config.parent ? this._getParent() : null if (!this._config.parent) { this._addAriaAndCollapsedClass(this._element, this._triggerArray) } - this._selectorActives = Selector.ACTIVES - if (this._parent) { - const childrenSelector = this._parent.hasAttribute(Selector.DATA_CHILDREN) ? this._parent.getAttribute(Selector.DATA_CHILDREN) : null - if (childrenSelector !== null) { - this._selectorActives = `${childrenSelector} > .show, ${childrenSelector} > .collapsing` - } - } - if (this._config.toggle) { this.toggle() } @@ -129,7 +121,7 @@ const Collapse = (($) => { let activesData if (this._parent) { - actives = $.makeArray($(this._parent).find(this._selectorActives)) + actives = $.makeArray($(this._parent).children().children(Selector.ACTIVES)) if (!actives.length) { actives = null } -- cgit v1.2.3