diff --git a/Gruntfile.js b/Gruntfile.js index a934eec88c..a54d4781b2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -246,6 +246,9 @@ module.exports = function (grunt) { cssmin: { options: { + // TODO: disable `zeroUnits` optimization once clean-css 3.2 is released + // and then simplify the fix for https://github.com/twbs/bootstrap/issues/14837 accordingly + compatibility: 'ie8', keepSpecialComments: '*', noAdvanced: true }, @@ -341,7 +344,7 @@ module.exports = function (grunt) { watch: { src: { files: '<%= jshint.core.src %>', - tasks: ['jshint:src', 'qunit', 'concat'] + tasks: ['jshint:core', 'qunit', 'concat'] }, test: { files: '<%= jshint.test.src %>', diff --git a/README.md b/README.md index 6a28344893..13785757b1 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,14 @@ To get started, check out ! ## Quick start -Four quick start options are available: +Several quick start options are available: -- [Download the latest release](https://github.com/twbs/bootstrap/archive/v3.3.2.zip). +- [Download the latest release](https://github.com/twbs/bootstrap/archive/v3.3.4.zip). - Clone the repo: `git clone https://github.com/twbs/bootstrap.git`. - Install with [Bower](http://bower.io): `bower install bootstrap`. - Install with [npm](https://www.npmjs.com): `npm install bootstrap`. -- Install with [Meteor](https://www.meteor.com/): `meteor add twbs:bootstrap`. +- Install with [Meteor](https://www.meteor.com): `meteor add twbs:bootstrap`. +- Install with [Composer](https://getcomposer.org): `composer require twbs/bootstrap`. Read the [Getting started page](http://getbootstrap.com/getting-started/) for information on the framework contents, templates and examples, and more. @@ -83,7 +84,7 @@ Documentation for v2.3.2 has been made available for the time being at . @@ -97,7 +98,7 @@ Keep track of development and community news. - Read and subscribe to [The Official Bootstrap Blog](http://blog.getbootstrap.com). - Chat with fellow Bootstrappers in IRC. On the `irc.freenode.net` server, in the `##bootstrap` channel. - Implementation help may be found at Stack Overflow (tagged [`twitter-bootstrap-3`](http://stackoverflow.com/questions/tagged/twitter-bootstrap-3)). -- Developers should use the keyword `bootstrap` on packages which modify or add to the functionality of Bootstrap when distributing through [npm](https://www.npmjs.com/browse/keyword/twbs-bootstrap) or similar delivery mechanisms for maximum discoverability. +- Developers should use the keyword `bootstrap` on packages which modify or add to the functionality of Bootstrap when distributing through [npm](https://www.npmjs.com/browse/keyword/bootstrap) or similar delivery mechanisms for maximum discoverability. diff --git a/_config.yml b/_config.yml index 1f63b36f9d..6dd22ada88 100644 --- a/_config.yml +++ b/_config.yml @@ -24,16 +24,16 @@ repo: https://github.com/twbs/bootstrap sass_repo: https://github.com/twbs/bootstrap-sass download: - source: https://github.com/twbs/bootstrap/archive/v3.3.2.zip - dist: https://github.com/twbs/bootstrap/releases/download/v3.3.2/bootstrap-3.3.2-dist.zip - sass: https://github.com/twbs/bootstrap-sass/archive/v3.3.2.tar.gz + source: https://github.com/twbs/bootstrap/archive/v3.3.4.zip + dist: https://github.com/twbs/bootstrap/releases/download/v3.3.4/bootstrap-3.3.4-dist.zip + sass: https://github.com/twbs/bootstrap-sass/archive/v3.3.4.tar.gz blog: http://blog.getbootstrap.com expo: http://expo.getbootstrap.com cdn: - css: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css - js: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js + css: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css + js: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js jquery: //code.jquery.com/jquery-2.1.1.min.js bug: diff --git a/bower.json b/bower.json index 3a45b2c327..27606caa81 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "bootstrap", "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", - "version": "3.3.2", + "version": "3.3.4", "keywords": [ "css", "js", diff --git a/docs/_data/browser-bugs.yml b/docs/_data/browser-bugs.yml index 690efef742..9888b5a3ba 100644 --- a/docs/_data/browser-bugs.yml +++ b/docs/_data/browser-bugs.yml @@ -118,6 +118,16 @@ origin: > Bootstrap#14409 +- + browser: > + Chrome + summary: > + `:focus` `outline` style causes cursor to not be displayed when toggling a `readonly` `` to read-write. + upstream_bug: > + Chromium#465274 + origin: > + Bootstrap#16022 + - browser: > Chrome (Windows & Linux) diff --git a/docs/_data/translations.yml b/docs/_data/translations.yml index 2340b99f15..3879fc34ce 100644 --- a/docs/_data/translations.yml +++ b/docs/_data/translations.yml @@ -42,3 +42,8 @@ code: uk description: Bootstrap українською url: http://twbs.docs.org.ua + +- name: Vietnamese + code: vi + description: Bootstrap bằng tiếng Việt + url: http://getbootstrap.com.vn diff --git a/docs/about/history.md b/docs/about/history.md index a2c9db14be..7d881fe07c 100644 --- a/docs/about/history.md +++ b/docs/about/history.md @@ -7,4 +7,4 @@ Originally created by a designer and a developer at Twitter, Bootstrap has becom Bootstrap was created at Twitter in mid-2010 by [@mdo](https://twitter.com/mdo) and [@fat](https://twitter.com/fat). Prior to being an open-sourced framework, Bootstrap was known as _Twitter Blueprint_. A few months into development, Twitter held its [first Hack Week](https://blog.twitter.com/2010/hack-week) and the project exploded as developers of all skill levels jumped in without any external guidance. It served as the style guide for internal tools development at the company for over a year before its public release, and continues to do so today. -Originally [released](https://dev.twitter.com/blog/bootstrap-twitter) on [](https://twitter.com/mdo/statuses/104620039650557952), we've since had over [twenty releases](https://github.com/twbs/bootstrap/releases), including two major rewrites with v2 and v3. With Bootstrap 2, we added responsive functionality to the entire framework as an optional stylesheet. Building on that with Bootstrap 3, we rewrote the library once more to make it responsive by default with a mobile first approach. \ No newline at end of file +Originally [released](https://blog.twitter.com/2011/bootstrap-twitter) on [](https://twitter.com/mdo/statuses/104620039650557952), we've since had over [twenty releases](https://github.com/twbs/bootstrap/releases), including two major rewrites with v2 and v3. With Bootstrap 2, we added responsive functionality to the entire framework as an optional stylesheet. Building on that with Bootstrap 3, we rewrote the library once more to make it responsive by default with a mobile first approach. \ No newline at end of file diff --git a/docs/getting-started/accessibility.md b/docs/getting-started/accessibility.md index c1a23da350..c20085ff85 100644 --- a/docs/getting-started/accessibility.md +++ b/docs/getting-started/accessibility.md @@ -5,7 +5,7 @@ title: Accessibility Bootstrap follows common web standards and—with minimal extra effort—can be used to create sites that are accessible to those using AT. -### Skip navigation +## Skip navigation If your navigation contains many links and comes before the main content in the DOM, add a `Skip to main content` link before the navigation (for a simple explanation, see this [A11Y Project article on skip navigation links](http://a11yproject.com/posts/skip-nav-links/)). Using the `.sr-only` class will visually hide the skip link, and the .sr-only-focusable class will ensure that the link becomes visible once focused (for sighted keyboard users). @@ -25,13 +25,13 @@ If your navigation contains many links and comes before the main content in the {% endhighlight %} -### Nested headings +## Nested headings When nesting headings (`

` - `

`), your primary document header should be an `

`. Subsequent headings should make logical use of `

` - `

` such that screen readers can construct a table of contents for your pages. Learn more at [HTML CodeSniffer](http://squizlabs.github.io/HTML_CodeSniffer/Standards/Section508/) and [Penn State's Accessability](http://accessibility.psu.edu/headings). -### Additional resources +## Additional resources - ["HTML Codesniffer" bookmarklet for identifying accessibility issues](https://github.com/squizlabs/HTML_CodeSniffer) - [The A11Y Project](http://a11yproject.com/) diff --git a/docs/getting-started/download.md b/docs/getting-started/download.md index 6bcf8dd009..8bebeea4cc 100644 --- a/docs/getting-started/download.md +++ b/docs/getting-started/download.md @@ -54,6 +54,19 @@ Bootstrap's `package.json` contains some additional metadata under the following - `less` - path to Bootstrap's main [Less](http://lesscss.org) source file - `style` - path to Bootstrap's non-minified CSS that's been precompiled using the default settings (no customization) +### Meteor + +{% highlight bash %} +$ meteor add twbs:bootstrap +{% endhighlight %} + +### Composer + +{% highlight bash %} +$ composer require twbs/bootstrap +{% endhighlight %} + + ### Autoprefixer required Bootstrap uses [Autoprefixer](https://github.com/postcss/autoprefixer) to deal with [CSS vendor prefixes](http://webdesign.about.com/od/css/a/css-vendor-prefixes.htm). If you're compiling Bootstrap from its source Sass and not using our Gruntfile, you'll need to integrate Autoprefixer into your build process yourself. If you're using precompiled Bootstrap or using our Gruntfile, you don't need to worry about this as Autoprefixer is already integrated into our Gruntfile. diff --git a/docs/getting-started/support.md b/docs/getting-started/support.md index 2a96dbef70..cf87535baf 100644 --- a/docs/getting-started/support.md +++ b/docs/getting-started/support.md @@ -5,7 +5,7 @@ title: Supported platforms Bootstrap is built to work best with the latest techniques. As such, older desktop and mobile browsers may display differently, but should remain fully functional. -### Supported browsers +## Supported browsers Bootstrap supports the **latest, stable releases** of all major browsers and platforms. On Windows, **we support Internet Explorer 9-11**. More specific support information is provided below. @@ -65,7 +65,7 @@ Unofficially, Bootstrap should look and behave well enough in Chromium and Chrom For a list of some of the browser bugs that Bootstrap has to grapple with, see our [Wall of browser bugs](../browser-bugs/). -### Internet Explorer 9 +## Internet Explorer 9 Internet Explorer 9 is also supported, however, please be aware that some CSS3 properties and HTML5 elements are not fully supported. @@ -104,7 +104,7 @@ Internet Explorer 9 is also supported, however, please be aware that some CSS3 p Visit [Can I use...](http://caniuse.com/) for details on browser support of CSS3 and HTML5 features. -### Supporting Internet Explorer 8 +## Supporting Internet Explorer 8 As of v4, Bootstrap no longer supports IE8. **If you require IE8 support, we recommend you use Bootstrap 3.** It's still supported by our team for bugfixes and documentation changes, but no new features will be added to it. @@ -114,7 +114,7 @@ Alternatively, you can add the some third party JavaScript to backfill support f * [Respond.js](https://github.com/scottjehl/Respond) * [Rem unit polyfill](https://github.com/chuckcarpenter/REM-unit-polyfill) -### IE Compatibility modes +## IE Compatibility modes Bootstrap is not supported in the old Internet Explorer compatibility modes. To be sure you're using the latest rendering mode for IE, consider including the appropriate `` tag in your pages: @@ -128,7 +128,7 @@ This tag is included in all of Bootstrap's documentation and examples to ensure See [this StackOverflow question](http://stackoverflow.com/questions/6771258/whats-the-difference-if-meta-http-equiv-x-ua-compatible-content-ie-edge) for more information. -### Internet Explorer 10 in Windows Phone 8 +## Internet Explorer 10 in Windows Phone 8 Internet Explorer 10 in Windows Phone 8 versions older than [Update 3 (a.k.a. GDR3)](http://blogs.windows.com/windows_phone/b/wpdev/archive/2013/10/14/introducing-windows-phone-preview-for-developers.aspx) doesn't differentiate **device width** from **viewport width** in `@-ms-viewport` at-rules, and thus doesn't properly apply the media queries in Bootstrap's CSS. To address this, you'll need to **include the following JavaScript to work around the bug**. @@ -148,30 +148,30 @@ For more information and usage guidelines, read [Windows Phone 8 and Device-Widt As a heads up, we include this in all of Bootstrap's documentation and examples as a demonstration. -### Modals, navbars, and virtual keyboards +## Modals, navbars, and virtual keyboards -#### Overflow and scrolling +### Overflow and scrolling Support for `overflow: hidden;` on the `` element is quite limited in iOS and Android. To that end, when you scroll past the top or bottom of a modal in either of those devices' browsers, the `` content will begin to scroll. -#### Virtual keyboards +### Virtual keyboards Also, note that if you're using a fixed navbar or using inputs within a modal, iOS has a rendering bug that doesn't update the position of fixed elements when the virtual keyboard is triggered. A few workarounds for this include transforming your elements to `position: absolute;` or invoking a timer on focus to try to correct the positioning manually. This is not handled by Bootstrap, so it is up to you to decide which solution is best for your application. -#### Navbar Dropdowns +### Navbar Dropdowns The `.dropdown-backdrop` element isn't used on iOS in the nav because of the complexity of z-indexing. Thus, to close dropdowns in navbars, you must directly click the dropdown element (or [any other element which will fire a click event in iOS](https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile)). -### Browser zooming +## Browser zooming Page zooming inevitably presents rendering artifacts in some components, both in Bootstrap and the rest of the web. Depending on the issue, we may be able to fix it (search first and then open an issue if need be). However, we tend to ignore these as they often have no direct solution other than hacky workarounds. -### Sticky `:hover`/`:focus` on mobile +## Sticky `:hover`/`:focus` on mobile Even though real hovering isn't possible on most touchscreens, most mobile browsers emulate hovering support and make `:hover` "sticky". In other words, `:hover` styles start applying after tapping an element and only stop applying after the user taps some other element. On mobile-first sites, this behavior is normally undesirable. Bootstrap includes a workaround for this, although it is disabled by default. By setting `$use-hover-media-query` to `true` when compiling from Sass, Bootstrap will use [mq4-hover-shim](https://github.com/twbs/mq4-hover-shim) to disable `:hover` styles in browsers that emulate hovering, thus preventing sticky `:hover` styles. There are some caveats to this workaround; see the shim's documentation for details. -### Printing +## Printing Even in some modern browsers, printing can be quirky. @@ -187,7 +187,7 @@ Also, as of Safari v8.0, fixed-width .containers can cause Safari t } {% endhighlight %} -### Android stock browser +## Android stock browser Out of the box, Android 4.1 (and even some newer releases apparently) ship with the Browser app as the default web browser of choice (as opposed to Chrome). Unfortunately, the Browser app has lots of bugs and inconsistencies with CSS in general. @@ -209,7 +209,7 @@ $(function () { Want to see an example? [Check out this JS Bin demo.](http://jsbin.com/OyaqoDO/2) -### Validators +## Validators In order to provide the best possible experience to old and buggy browsers, Bootstrap uses [CSS browser hacks](http://browserhacks.com) in several places to target special CSS to certain browser versions in order to work around bugs in the browsers themselves. These hacks understandably cause CSS validators to complain that they are invalid. In a couple places, we also use bleeding-edge CSS features that aren't yet fully standardized, but these are used purely for progressive enhancement. diff --git a/docs/getting-started/third-party-support.md b/docs/getting-started/third-party-support.md index 604290d028..00a74fce75 100644 --- a/docs/getting-started/third-party-support.md +++ b/docs/getting-started/third-party-support.md @@ -5,7 +5,7 @@ title: Third party support While we don't officially support any third party plugins or add-ons, we do offer some useful advice to help avoid potential issues in your projects. -### Box-sizing +## Box-sizing Some third-party software, including Google Maps and Google Custom Search Engine, conflict with Bootstrap due to `* { box-sizing: border-box; }`, a rule which makes it so `padding` does not affect the final computed width of an element. These widgets expect the box model to be `content-box` instead. Learn more about [box model and sizing at CSS Tricks](http://css-tricks.com/box-sizing/). diff --git a/js/.jscsrc b/js/.jscsrc index 982676e15f..caf1938f21 100644 --- a/js/.jscsrc +++ b/js/.jscsrc @@ -8,6 +8,7 @@ "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], "disallowSpaceBeforeBinaryOperators": [","], "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, "disallowSpacesInsideArrayBrackets": true, "disallowSpacesInsideParentheses": true, diff --git a/js/tests/README.md b/js/tests/README.md new file mode 100644 index 0000000000..6cdb41059b --- /dev/null +++ b/js/tests/README.md @@ -0,0 +1,61 @@ +## How does Bootstrap's test suite work? + +Bootstrap uses [QUnit](http://api.qunitjs.com/), a powerful, easy-to-use JavaScript unit test framework. Each plugin has a file dedicated to its tests in `unit/.js`. + +* `unit/` contains the unit test files for each Bootstrap plugin. +* `vendor/` contains third-party testing-related code (QUnit and jQuery). +* `visual/` contains "visual" tests which are run interactively in real browsers and require manual verification by humans. + +To run the unit test suite via [PhantomJS](http://phantomjs.org/), run `grunt test-js`. + +To run the unit test suite via a real web browser, open `index.html` in the browser. + + +## How do I add a new unit test? + +1. Locate and open the file dedicated to the plugin which you need to add tests to (`unit/.js`). +2. Review the [QUnit API Documentation](http://api.qunitjs.com/) and use the existing tests as references for how to structure your new tests. +3. Write the necessary unit test(s) for the new or revised functionality. +4. Run `grunt test-js` to see the results of your newly-added test(s). + +**Note:** Your new unit tests should fail before your changes are applied to the plugin, and should pass after your changes are applied to the plugin. + +## What should a unit test look like? + +* Each test should have a unique name clearly stating what unit is being tested. +* Each test should test only one unit per test, although one test can include several assertions. Create multiple tests for multiple units of functionality. +* Each test should begin with [`assert.expect`](http://api.qunitjs.com/expect/) to ensure that the expected assertions are run. +* Each test should follow the project's [JavaScript Code Guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md#js) + +### Example tests + +```javascript +// Synchronous test +QUnit.test('should describe the unit being tested', function (assert) { + assert.expect(1) + var templateHTML = '
' + + '×' + + '

Template necessary for the test.

' + + '
' + var $alert = $(templateHTML).appendTo('#qunit-fixture').bootstrapAlert() + + $alert.find('.close').click() + + // Make assertion + assert.strictEqual($alert.hasClass('in'), false, 'remove .in class on .close click') +}) + +// Asynchronous test +QUnit.test('should describe the unit being tested', function (assert) { + assert.expect(1) + var done = assert.async() + + $('
') + .appendTo('#qunit-fixture') + .on('shown.bs.tooltip', function () { + assert.ok(true, '"shown" event was fired after calling "show"') + done() + }) + .bootstrapTooltip('show') +}) +``` diff --git a/js/tests/index.html b/js/tests/index.html index c1b5b39141..d1ec0a7f40 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -7,19 +7,55 @@ + - diff --git a/js/tests/unit/.jshintrc b/js/tests/unit/.jshintrc index 682a49af1e..22e878512b 100644 --- a/js/tests/unit/.jshintrc +++ b/js/tests/unit/.jshintrc @@ -1,5 +1,6 @@ { "extends" : "../../.jshintrc", "devel" : true, + "es3" : false, "qunit" : true } diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index 75ae2d2ef8..6be990a518 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -4,6 +4,7 @@ $(function () { QUnit.module('alert plugin') QUnit.test('should be defined on jquery object', function (assert) { + assert.expect(1) assert.ok($(document.body).alert, 'alert method is defined') }) @@ -19,10 +20,12 @@ $(function () { }) QUnit.test('should provide no conflict', function (assert) { + assert.expect(1) assert.strictEqual($.fn.alert, undefined, 'alert was set back to undefined (org value)') }) QUnit.test('should return jquery collection containing the element', function (assert) { + assert.expect(2) var $el = $('
') var $alert = $el.bootstrapAlert() assert.ok($alert instanceof $, 'returns jquery collection') @@ -30,18 +33,20 @@ $(function () { }) QUnit.test('should fade element out on clicking .close', function (assert) { + assert.expect(1) var alertHTML = '
' + '×' + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + '
' var $alert = $(alertHTML).bootstrapAlert() - $alert.find('.close').click() + $alert.find('.close').trigger('click') assert.strictEqual($alert.hasClass('in'), false, 'remove .in class on .close click') }) QUnit.test('should remove element when clicking .close', function (assert) { + assert.expect(2) var alertHTML = '
' + '×' + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' @@ -50,12 +55,13 @@ $(function () { assert.notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom') - $alert.find('.close').click() + $alert.find('.close').trigger('click') assert.strictEqual($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom') }) QUnit.test('should not fire closed when close is prevented', function (assert) { + assert.expect(1) var done = assert.async() $('
') .on('close.bs.alert', function (e) { diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index a4d5eec67b..0f1b7b119f 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -4,6 +4,7 @@ $(function () { QUnit.module('collapse plugin') QUnit.test('should be defined on jquery object', function (assert) { + assert.expect(1) assert.ok($(document.body).collapse, 'collapse method is defined') }) @@ -19,10 +20,12 @@ $(function () { }) QUnit.test('should provide no conflict', function (assert) { + assert.expect(1) assert.strictEqual($.fn.collapse, undefined, 'collapse was set back to undefined (org value)') }) QUnit.test('should return jquery collection containing the element', function (assert) { + assert.expect(2) var $el = $('
') var $collapse = $el.bootstrapCollapse() assert.ok($collapse instanceof $, 'returns jquery collection') @@ -30,6 +33,7 @@ $(function () { }) QUnit.test('should show a collapsed element', function (assert) { + assert.expect(2) var $el = $('
').bootstrapCollapse('show') assert.ok($el.hasClass('in'), 'has class "in"') @@ -37,13 +41,14 @@ $(function () { }) QUnit.test('should hide a collapsed element', function (assert) { + assert.expect(1) var $el = $('
').bootstrapCollapse('hide') assert.ok(!$el.hasClass('in'), 'does not have class "in"') - assert.ok(/height/i.test($el.attr('style')), 'has height set') }) QUnit.test('should not fire shown when show is prevented', function (assert) { + assert.expect(1) var done = assert.async() $('
') @@ -59,6 +64,7 @@ $(function () { }) QUnit.test('should reset style to auto after finishing opening collapse', function (assert) { + assert.expect(2) var done = assert.async() $('
') @@ -73,9 +79,10 @@ $(function () { }) QUnit.test('should remove "collapsed" class from target when collapse is shown', function (assert) { + assert.expect(1) var done = assert.async() - var $target = $('
').appendTo('#qunit-fixture') + var $target = $('').appendTo('#qunit-fixture') $('
') .appendTo('#qunit-fixture') @@ -99,14 +107,15 @@ $(function () { done() }) - $target.click() + $target.trigger('click') }) QUnit.test('should remove "collapsed" class from all triggers targeting the collapse when the collapse is shown', function (assert) { + assert.expect(2) var done = assert.async() - var $target = $('
').appendTo('#qunit-fixture') - var $alt = $('').appendTo('#qunit-fixture') + var $target = $('').appendTo('#qunit-fixture') + var $alt = $('').appendTo('#qunit-fixture') $('
') .appendTo('#qunit-fixture') @@ -133,13 +143,12 @@ $(function () { done() }) - $target.click() + $target.trigger('click') }) - QUnit.test('should not close a collapse when initialized with "show" if already shown', function (assert) { - var done = assert.async() - + QUnit.test('should not close a collapse when initialized with "show" option if already shown', function (assert) { assert.expect(0) + var done = assert.async() var $test = $('
') .appendTo('#qunit-fixture') @@ -152,10 +161,9 @@ $(function () { setTimeout(done, 0) }) - QUnit.test('should open a collapse when initialized with "show" if not already shown', function (assert) { - var done = assert.async() - + QUnit.test('should open a collapse when initialized with "show" option if not already shown', function (assert) { assert.expect(1) + var done = assert.async() var $test = $('
') .appendTo('#qunit-fixture') @@ -168,7 +176,36 @@ $(function () { setTimeout(done, 0) }) + QUnit.test('should not show a collapse when initialized with "hide" option if already hidden', function (assert) { + assert.expect(0) + var done = assert.async() + + $('
') + .appendTo('#qunit-fixture') + .on('show.bs.collapse', function () { + assert.ok(false, 'showing a previously-uninitialized hidden collapse when the "hide" method is called') + }) + .bootstrapCollapse('hide') + + setTimeout(done, 0) + }) + + QUnit.test('should hide a collapse when initialized with "hide" option if not already hidden', function (assert) { + assert.expect(1) + var done = assert.async() + + $('
') + .appendTo('#qunit-fixture') + .on('hide.bs.collapse', function () { + assert.ok(true, 'hiding a previously-uninitialized shown collapse when the "hide" method is called') + }) + .bootstrapCollapse('hide') + + setTimeout(done, 0) + }) + QUnit.test('should remove "collapsed" class from active accordion target', function (assert) { + assert.expect(3) var done = assert.async() var accordionHTML = '
' @@ -178,15 +215,15 @@ $(function () { + '
' var $groups = $(accordionHTML).appendTo('#qunit-fixture').find('.panel') - var $target1 = $('
').appendTo($groups.eq(0)) + var $target1 = $('').appendTo($groups.eq(0)) $('
').appendTo($groups.eq(0)) - var $target2 = $('
').appendTo($groups.eq(0)) + var $target1 = $('').appendTo($groups.eq(0)) $('
').appendTo($groups.eq(0)) - var $target2 = $('
').appendTo('#qunit-fixture') + var $target = $('').appendTo('#qunit-fixture') $('
') .appendTo('#qunit-fixture') @@ -261,14 +301,15 @@ $(function () { done() }) - $target.click() + $target.trigger('click') }) QUnit.test('should set aria-expanded="true" on all triggers targeting the collapse when the collapse is shown', function (assert) { + assert.expect(2) var done = assert.async() - var $target = $('
').appendTo('#qunit-fixture') - var $alt = $('').appendTo('#qunit-fixture') + var $target = $('').appendTo('#qunit-fixture') + var $alt = $('').appendTo('#qunit-fixture') $('
') .appendTo('#qunit-fixture') @@ -295,10 +337,11 @@ $(function () { done() }) - $target.click() + $target.trigger('click') }) QUnit.test('should change aria-expanded from active accordion target to "false" and set the newly active one to "true"', function (assert) { + assert.expect(3) var done = assert.async() var accordionHTML = '
' @@ -308,15 +351,15 @@ $(function () { + '
' var $groups = $(accordionHTML).appendTo('#qunit-fixture').find('.panel') - var $target1 = $('
').appendTo($groups.eq(0)) + var $target1 = $('').appendTo($groups.eq(0)) $('
').appendTo($groups.eq(0)) - var $target2 = $('