Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #15354, #15315: Uninitialized collapsibles should not toggle on .collapse('hide') #15807

Closed
wants to merge 3 commits into from

Conversation

Nikita240
Copy link
Contributor

Fix #15315
Fix #15354

When you do this
image

You get this
image

The unit test would execute `hide` on an already hidden element, and
then check if it has height set (which is added by the transition). This
only worked previously, because collapse.js erroniuosly executed
`toggle` which then trigged `show` instead of `hide`. Now that `hide` is
actually executed, no transition happens, so the height value is not set
by the animation. Hence in order to test the `hide` animation, the
element must first be shown.
@twbs-savage
Copy link

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: b13efde
Build details: https://travis-ci.org/twbs-savage/bootstrap/builds/50697412

(Please note that this is a fully automated comment.)

@cvrebert cvrebert added the js label Feb 13, 2015
@vsn4ik
Copy link
Contributor

vsn4ik commented Feb 14, 2015

/^(show|hide)$/.test(option) is shorter.

@Nikita240
Copy link
Contributor Author

@vsn4ik I don't understand that.

@vsn4ik
Copy link
Contributor

vsn4ik commented Feb 16, 2015

if (option == 'show' || option == 'hide') { ... }

equivalent

if (/^(show|hide)$/.test(option)) { ... }

@kkirsche
Copy link
Contributor

only question I would ask @vsn4ik is while that is shorter I question if it sacrifices readability for such a small gain.

@vsn4ik
Copy link
Contributor

vsn4ik commented Feb 16, 2015

Indeed. 👍 for the long version.

@Nikita240
Copy link
Contributor Author

@vsn4ik Holy crap what syntax is that?

@kkirsche
Copy link
Contributor

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test explains it. It's just a regular expression tester

Please excuse brevity — Sent from my mobile device.

On Feb 16, 2015, at 6:52 PM, Nikita Rushmanov notifications@github.com wrote:

@vsn4ik Holy crap what syntax is that?


Reply to this email directly or view it on GitHub.

@Nikita240
Copy link
Contributor Author

Ooooooh it's regex. That makes a lot more sense.

@cvrebert
Copy link
Collaborator

@Nikita240 Can you remove the .min.* files from this PR? They cause unnecessary merge conflicts.

@cvrebert cvrebert changed the title [Fix Issue #15354, #15315] Uninitialized collapsibles should not toggle on .collapse('hide') Fix #15354, #15315: Uninitialized collapsibles should not toggle on .collapse('hide') Feb 21, 2015
@Nikita240
Copy link
Contributor Author

@cvrebert Did I do it right?

@twbs-savage
Copy link

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: d9981ae
Build details: https://travis-ci.org/twbs-savage/bootstrap/builds/51680981

(Please note that this is a fully automated comment.)

@cvrebert
Copy link
Collaborator

Not quite, but it's not a big deal. Don't worry about it.

CC: @fat for review

@@ -37,7 +37,7 @@ $(function () {
})

test('should hide a collapsed element', function () {
var $el = $('<div class="collapse"/>').bootstrapCollapse('hide')
var $el = $('<div class="collapse in"/>').bootstrapCollapse('hide')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Collapsible with .collapse.in is in the shown/expanded (i.e. non-collapsed) state, so this change is invalid per the name of the test, AFAICT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I just have to rename the test.

cvrebert added a commit that referenced this pull request Mar 6, 2015
@cvrebert
Copy link
Collaborator

cvrebert commented Mar 6, 2015

Superseded by #16011.

@cvrebert cvrebert closed this Mar 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants