Skip to content

Commit

Permalink
Merge branch 'v4-dev' into v4dev-mc-backport-30353
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 19, 2020
2 parents 9425f6f + 8b6dd44 commit 3f6fc9c
Show file tree
Hide file tree
Showing 20 changed files with 3,568 additions and 2,108 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/test.yml
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [6, 8, 12]
node: [10, 12]
ruby: [2.4.x]

steps:
Expand All @@ -23,7 +23,7 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Set up Ruby 2.4
- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand All @@ -38,7 +38,6 @@ jobs:
key: ${{ runner.os }}-ruby-v${{ matrix.ruby }}-${{ hashFiles('Gemfile') }}-${{ hashFiles('Gemfile.lock') }}-${{ hashFiles('.github/workflows/test.yml') }}
restore-keys: |
${{ runner.os }}-ruby-v${{ matrix.ruby }}-${{ hashFiles('Gemfile') }}-${{ hashFiles('Gemfile.lock') }}-${{ hashFiles('.github/workflows/test.yml') }}
${{ runner.os }}-ruby-v${{ matrix.ruby }}-
- name: Set up npm cache
uses: actions/cache@v1
Expand All @@ -47,11 +46,13 @@ jobs:
key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/test.yml') }}
restore-keys: |
${{ runner.OS }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/test.yml') }}
${{ runner.OS }}-node-v${{ matrix.node }}-
- name: Set up Bundler
run: gem install bundler -v "~> 1.17"

- name: Update rubygems
run: gem update --system

- run: ruby --version
- run: gem --version
- run: bundle --version
Expand All @@ -60,34 +61,30 @@ jobs:
- run: java -version

- name: Install npm dependencies
run: npm install
run: npm ci

- name: Install bundler dependencies
run: bundle install --deployment --jobs=3 --retry=3 --clean
run: bundle install --deployment --jobs=4 --retry=3 --clean

- name: Run tests
run: npm test

- name: Run bundlesize
run: npm run bundlesize
if: matrix.node == 8
if: matrix.node == 10
env:
BUNDLESIZE_GITHUB_TOKEN: "${{ secrets.BUNDLESIZE_GITHUB_TOKEN }}"

- name: Run BrowserStack tests
run: npm run js-test-cloud
if: matrix.node == 8 && github.repository == 'twbs/bootstrap' && github.event_name == 'push'
if: matrix.node == 10 && github.repository == 'twbs/bootstrap' && github.event_name == 'push'
env:
BROWSER_STACK_ACCESS_KEY: "${{ secrets.BROWSER_STACK_ACCESS_KEY }}"
BROWSER_STACK_USERNAME: "${{ secrets.BROWSER_STACK_USERNAME }}"

- name: Run Link Checker
run: npm run check-broken-links
if: matrix.node == 8

- name: Run Coveralls
uses: coverallsapp/github-action@master
if: matrix.node == 8
if: matrix.node == 10
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
path-to-lcov: "./js/coverage/lcov.info"
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
# Ignore docs files
/_gh_pages/
/site/.jekyll-cache
/site/.jekyll-metadata
/site/docs/**/dist/
# Hugo folders
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

group :development, :test do
gem 'jekyll', '~> 3.8.6'
gem 'jekyll', '~> 4.0.0'
gem 'jekyll-redirect-from', '~> 0.16.0'
gem 'jekyll-sitemap', '~> 1.4.0'
gem 'jekyll-toc', '~> 0.13.1'
Expand Down
40 changes: 23 additions & 17 deletions Gemfile.lock
Expand Up @@ -14,42 +14,46 @@ GEM
ffi (1.12.2-x64-mingw32)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (0.9.5)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
jekyll (3.8.6)
jekyll (4.0.0)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 0.7)
jekyll-sass-converter (~> 1.0)
i18n (>= 0.9.5, < 2)
jekyll-sass-converter (~> 2.0)
jekyll-watch (~> 2.0)
kramdown (~> 1.14)
kramdown (~> 2.1)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (~> 0.3.3)
pathutil (~> 0.9)
rouge (>= 1.7, < 4)
rouge (~> 3.0)
safe_yaml (~> 1.0)
terminal-table (~> 1.8)
jekyll-redirect-from (0.16.0)
jekyll (>= 3.3, < 5.0)
jekyll-sass-converter (1.5.2)
sass (~> 3.4)
jekyll-sass-converter (2.1.0)
sassc (> 2.0.1, < 3.0)
jekyll-sitemap (1.4.0)
jekyll (>= 3.7, < 5.0)
jekyll-toc (0.13.1)
jekyll (>= 3.7)
nokogiri (~> 1.9)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (1.17.0)
kramdown (2.1.0)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
mini_portile2 (2.4.0)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
nokogiri (1.10.8-x64-mingw32)
nokogiri (1.10.9-x64-mingw32)
mini_portile2 (~> 2.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
Expand All @@ -59,19 +63,21 @@ GEM
ffi (~> 1.0)
rouge (3.16.0)
safe_yaml (1.0.5)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sassc (2.2.1)
ffi (~> 1.9)
sassc (2.2.1-x64-mingw32)
ffi (~> 1.9)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.6.1)
wdm (0.1.1)

PLATFORMS
ruby
x64-mingw32

DEPENDENCIES
jekyll (~> 3.8.6)
jekyll (~> 4.0.0)
jekyll-redirect-from (~> 0.16.0)
jekyll-sitemap (~> 1.4.0)
jekyll-toc (~> 0.13.1)
Expand Down
2 changes: 1 addition & 1 deletion build/rollup.config.js
Expand Up @@ -2,7 +2,7 @@

const path = require('path')
const babel = require('rollup-plugin-babel')
const resolve = require('rollup-plugin-node-resolve')
const resolve = require('@rollup/plugin-node-resolve')
const banner = require('./banner.js')

const BUNDLE = process.env.BUNDLE === 'true'
Expand Down
35 changes: 19 additions & 16 deletions build/ship.sh
@@ -1,4 +1,7 @@
#!/usr/bin/env bash

set -e

#
# Usage
# ---------------
Expand All @@ -18,35 +21,35 @@ end=$'\e[0m'
current_version=$(node -p "require('./package.json').version")

if [[ $# -lt 1 ]]; then
printf "\n%s⚠️ Shipping aborted. You must specify a version.\n%s" $red $end
printf "\n%s⚠️ Shipping aborted. You must specify a version.\n%s" "$red" "$end"
exit 1
fi

# Pulling latest changes, just to be sure
printf "\n%s=======================================================%s" $magenta $end
printf "\n%sPulling latest changes...%s" $magenta $end
printf "\n%s=======================================================\n\n%s" $magenta $end
printf "\n%s=======================================================%s" "$magenta" "$end"
printf "\n%sPulling latest changes...%s" "$magenta" "$end"
printf "\n%s=======================================================\n\n%s" "$magenta" "$end"
git pull origin v4-dev

# Update version number
printf "\n%s=======================================================%s" $magenta $end
printf "\n%sUpdating version number...%s" $magenta $end
printf "\n%s=======================================================\n%s" $magenta $end
printf "\n%s=======================================================%s" "$magenta" "$end"
printf "\n%sUpdating version number...%s" "$magenta" "$end"
printf "\n%s=======================================================\n%s" "$magenta" "$end"
npm run release-version "$current_version" "$1"

# Build release
printf "\n%s=======================================================%s" $magenta $end
printf "\n%sBuilding release...%s" $magenta $end
printf "\n%s=======================================================\n%s" $magenta $end
printf "\n%s=======================================================%s" "$magenta" "$end"
printf "\n%sBuilding release...%s" "$magenta" "$end"
printf "\n%s=======================================================\n%s" "$magenta" "$end"
npm run release

# Copy the contents of the built docs site over to `bs-docs` repo
printf "\n%s=======================================================%s" $magenta $end
printf "\n%sCopy it over...%s" $magenta $end
printf "\n%s=======================================================\n%s" $magenta $end
printf "\n%s=======================================================%s" "$magenta" "$end"
printf "\n%sCopy it over...%s" "$magenta" "$end"
printf "\n%s=======================================================\n%s" "$magenta" "$end"
cp -rf _gh_pages/. ../bs-docs/
printf "\nDone!\n"

printf "\n%s=======================================================%s" $green $end
printf "\n%sSuccess, $1 is ready to review and publish.%s" $green $end
printf "\n%s=======================================================\n\n%s" $green $end
printf "\n%s=======================================================%s" "$green" "$end"
printf "\n%sSuccess, $1 is ready to review and publish.%s" "$green" "$end"
printf "\n%s=======================================================\n\n%s" "$green" "$end"
16 changes: 8 additions & 8 deletions js/src/button.js
Expand Up @@ -84,17 +84,13 @@ class Button {
$(activeElement).removeClass(ClassName.ACTIVE)
}
}
} else if (input.type === 'checkbox') {
if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName.ACTIVE)) {
triggerChangeEvent = false
}
} else {
// if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
triggerChangeEvent = false
}

if (triggerChangeEvent) {
input.checked = !this._element.classList.contains(ClassName.ACTIVE)
// if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
if (input.type === 'checkbox' || input.type === 'radio') {
input.checked = !this._element.classList.contains(ClassName.ACTIVE)
}
$(input).trigger('change')
}

Expand Down Expand Up @@ -147,6 +143,7 @@ class Button {
$(document)
.on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, (event) => {
let button = event.target
const initialButton = button

if (!$(button).hasClass(ClassName.BUTTON)) {
button = $(button).closest(Selector.BUTTON)[0]
Expand All @@ -162,6 +159,9 @@ $(document)
return
}

if (initialButton.tagName === 'LABEL' && inputBtn && inputBtn.type === 'checkbox') {
event.preventDefault() // work around event sent to label and input
}
Button._jQueryInterface.call($(button), 'toggle')
}
})
Expand Down
4 changes: 2 additions & 2 deletions js/tests/integration/rollup.bundle.js
@@ -1,7 +1,7 @@
/* eslint-env node */

const resolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const resolve = require('@rollup/plugin-node-resolve')
const commonjs = require('@rollup/plugin-commonjs')
const babel = require('rollup-plugin-babel')

module.exports = {
Expand Down
30 changes: 29 additions & 1 deletion js/tests/unit/button.js
Expand Up @@ -181,7 +181,7 @@ $(function () {
})

QUnit.test('should check for closest matching toggle', function (assert) {
assert.expect(12)
assert.expect(18)
var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
'<label class="btn btn-primary active">' +
'<input type="radio" name="options" id="option1" checked="true"> Option 1' +
Expand Down Expand Up @@ -213,6 +213,13 @@ $(function () {
assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked')
assert.ok($btn2.hasClass('active'), 'btn2 has active class')
assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked')
$btn1.bootstrapButton('toggle')
assert.ok($btn1.hasClass('active'), 'btn1 has active class')
assert.ok($btn1.find('input').prop('checked'), 'btn1 prop is checked')
assert.ok($btn1.find('input')[0].checked, 'btn1 is checked with jquery')
assert.ok(!$btn2.hasClass('active'), 'btn2 does not have active class')
assert.ok(!$btn2.find('input').prop('checked'), 'btn2 is not checked')
assert.ok(!$btn2.find('input')[0].checked, 'btn2 is not checked')
})

QUnit.test('should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group', function (assert) {
Expand Down Expand Up @@ -309,6 +316,27 @@ $(function () {
assert.ok($input.prop('checked'), 'checkbox is checked after click')
})

QUnit.test('should correctly set checked state on input and active class on the label when using button toggle', function (assert) {
assert.expect(6)
var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
'<label class="btn">' +
'<input type="checkbox">' +
'</label>' +
'</div>'
var $group = $(groupHTML).appendTo('#qunit-fixture')

var $btn = $group.children().eq(0)
var $input = $btn.children().eq(0)

assert.ok($btn.is(':not(.active)'), '<label> is initially not active')
assert.ok(!$input.prop('checked'), 'checkbox property is initially not checked')
assert.ok(!$input[0].checked, 'checkbox is not checked by jquery after click')
$btn.bootstrapButton('toggle')
assert.ok($btn.is('.active'), '<label> is active after click')
assert.ok($input.prop('checked'), 'checkbox property is checked after click')
assert.ok($input[0].checked, 'checkbox is checked by jquery after click')
})

QUnit.test('should not do anything if the click was just sent to the outer container with data-toggle', function (assert) {
assert.expect(4)
var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
Expand Down

0 comments on commit 3f6fc9c

Please sign in to comment.