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

v4-dev backports and updates #30710

Merged
merged 9 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: "Code Scanning - Action"

on:
push:
pull_request:
schedule:
- cron: "0 0 * * 0"

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ group :development, :test do
gem 'jekyll', '~> 4.0.0'
gem 'jekyll-redirect-from', '~> 0.16.0'
gem 'jekyll-sitemap', '~> 1.4.0'
gem 'jekyll-toc', '~> 0.13.1'
gem 'jekyll-toc', '~> 0.14.0'
gem 'wdm', '~> 0.1.1', :install_if => Gem.win_platform?
end
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ GEM
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-toc (0.14.0)
jekyll (>= 3.8)
nokogiri (~> 1.10)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.2.1)
Expand All @@ -59,7 +59,7 @@ GEM
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.4)
rb-fsevent (0.10.3)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.4)
Expand All @@ -82,7 +82,7 @@ DEPENDENCIES
jekyll (~> 4.0.0)
jekyll-redirect-from (~> 0.16.0)
jekyll-sitemap (~> 1.4.0)
jekyll-toc (~> 0.13.1)
jekyll-toc (~> 0.14.0)
wdm (~> 0.1.1)

BUNDLED WITH
Expand Down
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ cdn:
js_hash: "sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
js_bundle: "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"
js_bundle_hash: "sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm"
jquery: "https://code.jquery.com/jquery-3.5.0.slim.min.js"
jquery_hash: "sha384-/IFzzQmt1S744I+IQO4Mc1uphkxbXt1tEwjQ/qSw2p8pXWck09sLvqHmKDYYwReJ"
jquery: "https://code.jquery.com/jquery-3.5.1.slim.min.js"
jquery_hash: "sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
popper: "https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
popper_hash: "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"

Expand Down
13 changes: 13 additions & 0 deletions build/babel-helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

// These are the babel helpers we whitelist
const helpers = [
'createClass',
'createSuper',
'defineProperties',
'defineProperty',
'inheritsLoose',
'objectSpread2'
]

module.exports = helpers
53 changes: 29 additions & 24 deletions build/build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ const path = require('path')
const rollup = require('rollup')
const babel = require('rollup-plugin-babel')
const banner = require('./banner.js')
const babelHelpers = require('./babel-helpers.js')

const TEST = process.env.NODE_ENV === 'test'
const plugins = [
babel({
exclude: 'node_modules/**', // Only transpile our source code
externalHelpersWhitelist: [ // Include only required helpers
'defineProperties',
'createClass',
'createSuper',
'inheritsLoose',
'defineProperty',
'objectSpread2'
]
// Only transpile our source code
exclude: 'node_modules/**',
// Include only required helpers
externalHelpersWhitelist: babelHelpers
})
]
const bsPlugins = {
Expand All @@ -42,7 +38,7 @@ const bsPlugins = {
}
const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/'

function build(plugin) {
const build = async (plugin) => {
console.log(`Building ${plugin} plugin...`)

const external = ['jquery', 'popper.js']
Expand All @@ -64,23 +60,32 @@ function build(plugin) {
}

const pluginFilename = `${plugin.toLowerCase()}.js`

rollup.rollup({
const bundle = await rollup.rollup({
input: bsPlugins[plugin],
plugins,
external
}).then((bundle) => {
bundle.write({
banner: banner(pluginFilename),
format: 'umd',
name: plugin,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${rootPath}${pluginFilename}`)
})
.then(() => console.log(`Building ${plugin} plugin... Done!`))
.catch((err) => console.error(`${plugin}: ${err}`))
})

await bundle.write({
banner: banner(pluginFilename),
format: 'umd',
name: plugin,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${rootPath}${pluginFilename}`)
})

console.log(`Building ${plugin} plugin... Done!`)
}

const main = async () => {
try {
await Promise.all(Object.keys(bsPlugins).map((plugin) => build(plugin)))
} catch (error) {
console.error(error)

process.exit(1)
}
}

Object.keys(bsPlugins).forEach((plugin) => build(plugin))
main()
14 changes: 5 additions & 9 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ const path = require('path')
const babel = require('rollup-plugin-babel')
const resolve = require('@rollup/plugin-node-resolve')
const banner = require('./banner.js')
const babelHelpers = require('./babel-helpers.js')

const BUNDLE = process.env.BUNDLE === 'true'

let fileDest = 'bootstrap.js'
const external = ['jquery', 'popper.js']
const plugins = [
babel({
exclude: 'node_modules/**', // Only transpile our source code
externalHelpersWhitelist: [ // Include only required helpers
'defineProperties',
'createClass',
'createSuper',
'inheritsLoose',
'defineProperty',
'objectSpread2'
]
// Only transpile our source code
exclude: 'node_modules/**',
// Include only required helpers
externalHelpersWhitelist: babelHelpers
})
]
const globals = {
Expand Down
7 changes: 2 additions & 5 deletions js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,8 @@ class Modal {
}

_checkScrollbar() {
const {
left, right
} = document.body.getBoundingClientRect()

this._isBodyOverflowing = Math.floor(left + right) < window.innerWidth
const rect = document.body.getBoundingClientRect()
this._isBodyOverflowing = rect.left + rect.right < window.innerWidth
this._scrollbarWidth = this._getScrollbarWidth()
}

Expand Down
5 changes: 2 additions & 3 deletions js/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class ScrollSpy {
...typeof config === 'object' && config ? config : {}
}

if (typeof config.target !== 'string') {
if (typeof config.target !== 'string' && Util.isElement(config.target)) {
let id = $(config.target).attr('id')
if (!id) {
id = Util.getUID(NAME)
Expand Down Expand Up @@ -214,8 +214,7 @@ class ScrollSpy {
return
}

const offsetLength = this._offsets.length
for (let i = offsetLength; i--;) {
for (let i = this._offsets.length; i--;) {
const isActiveTarget = this._activeTarget !== this._targets[i] &&
scrollTop >= this._offsets[i] &&
(typeof this._offsets[i + 1] === 'undefined' ||
Expand Down
2 changes: 1 addition & 1 deletion js/tests/unit/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ $(function () {
.show()
.find('#scrollspy-example')
.bootstrapScrollspy({
target: document.getElementById('#ss-target')
target: document.getElementById('ss-target')
})

$scrollspy.one('scroll', function () {
Expand Down