Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored Jun 18, 2020
2 parents aa7af42 + ffbdb08 commit 0347adb
Show file tree
Hide file tree
Showing 22 changed files with 119 additions and 136 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bundlewatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ jobs:
run: npm run bundlewatch
env:
BUNDLEWATCH_GITHUB_TOKEN: "${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}"
CI_BRANCH_BASE: main
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ Read the [Getting started page](https://v5.getbootstrap.com/docs/5.0/getting-sta

[![Slack](https://bootstrap-slack.herokuapp.com/badge.svg)](https://bootstrap-slack.herokuapp.com/)
[![Build Status](https://github.com/twbs/bootstrap/workflows/JS%20Tests/badge.svg?branch=main)](https://github.com/twbs/bootstrap/actions?query=workflow%3AJS+Tests+branch%3Amain)
[![npm version](https://img.shields.io/npm/v/bootstrap.svg)](https://www.npmjs.com/package/bootstrap)
[![Gem version](https://img.shields.io/gem/v/bootstrap.svg)](https://rubygems.org/gems/bootstrap)
[![Meteor Atmosphere](https://img.shields.io/badge/meteor-twbs%3Abootstrap-blue.svg)](https://atmospherejs.com/twbs/bootstrap)
[![Packagist Prerelease](https://img.shields.io/packagist/vpre/twbs/bootstrap.svg)](https://packagist.org/packages/twbs/bootstrap)
[![NuGet](https://img.shields.io/nuget/vpre/bootstrap.svg)](https://www.nuget.org/packages/bootstrap/absoluteLatest)
[![peerDependencies Status](https://img.shields.io/david/peer/twbs/bootstrap.svg)](https://david-dm.org/twbs/bootstrap?type=peer)
[![devDependency Status](https://img.shields.io/david/dev/twbs/bootstrap.svg)](https://david-dm.org/twbs/bootstrap?type=dev)
[![Coverage Status](https://img.shields.io/coveralls/github/twbs/bootstrap/main.svg)](https://coveralls.io/github/twbs/bootstrap?branch=main)
[![CSS gzip size](https://img.badgesize.io/twbs/bootstrap/main/dist/css/bootstrap.min.css?compression=gzip&label=CSS+gzip+size)](https://github.com/twbs/bootstrap/tree/main/dist/css/bootstrap.min.css)
[![JS gzip size](https://img.badgesize.io/twbs/bootstrap/main/dist/js/bootstrap.min.js?compression=gzip&label=JS+gzip+size)](https://github.com/twbs/bootstrap/tree/main/dist/js/bootstrap.min.js)
[![npm version](https://img.shields.io/npm/v/bootstrap)](https://www.npmjs.com/package/bootstrap)
[![Gem version](https://img.shields.io/gem/v/bootstrap)](https://rubygems.org/gems/bootstrap)
[![Meteor Atmosphere](https://img.shields.io/badge/meteor-twbs%3Abootstrap-blue)](https://atmospherejs.com/twbs/bootstrap)
[![Packagist Prerelease](https://img.shields.io/packagist/vpre/twbs/bootstrap)](https://packagist.org/packages/twbs/bootstrap)
[![NuGet](https://img.shields.io/nuget/vpre/bootstrap)](https://www.nuget.org/packages/bootstrap/absoluteLatest)
[![peerDependencies Status](https://img.shields.io/david/peer/twbs/bootstrap)](https://david-dm.org/twbs/bootstrap?type=peer)
[![devDependency Status](https://img.shields.io/david/dev/twbs/bootstrap)](https://david-dm.org/twbs/bootstrap?type=dev)
[![Coverage Status](https://img.shields.io/coveralls/github/twbs/bootstrap/main)](https://coveralls.io/github/twbs/bootstrap?branch=main)
[![CSS gzip size](https://img.badgesize.io/twbs/bootstrap/main/dist/css/bootstrap.min.css?compression=gzip&label=CSS%20gzip%20size)](https://github.com/twbs/bootstrap/tree/main/dist/css/bootstrap.min.css)
[![JS gzip size](https://img.badgesize.io/twbs/bootstrap/main/dist/js/bootstrap.min.js?compression=gzip&label=JS%20gzip%20size)](https://github.com/twbs/bootstrap/tree/main/dist/js/bootstrap.min.js)
[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=SkxZcStBeExEdVJqQ2hWYnlWckpkNmNEY213SFp6WHFETWk2bGFuY3pCbz0tLXhqbHJsVlZhQnRBdEpod3NLSDMzaHc9PQ==--3d0b75245708616eb93113221beece33e680b229)](https://www.browserstack.com/automate/public-build/SkxZcStBeExEdVJqQ2hWYnlWckpkNmNEY213SFp6WHFETWk2bGFuY3pCbz0tLXhqbHJsVlZhQnRBdEpod3NLSDMzaHc9PQ==--3d0b75245708616eb93113221beece33e680b229)
[![Backers on Open Collective](https://img.shields.io/opencollective/backers/bootstrap.svg)](#backers)
[![Sponsors on Open Collective](https://img.shields.io/opencollective/sponsors/bootstrap.svg)](#sponsors)
[![Backers on Open Collective](https://img.shields.io/opencollective/backers/bootstrap)](#backers)
[![Sponsors on Open Collective](https://img.shields.io/opencollective/sponsors/bootstrap)](#sponsors)


## What's included
Expand Down
9 changes: 2 additions & 7 deletions js/src/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ class Alert {
// Public

close(element) {
let rootElement = this._element
if (element) {
rootElement = this._getRootElement(element)
}

const rootElement = element ? this._getRootElement(element) : this._element
const customEvent = this._triggerCloseEvent(rootElement)

if (customEvent === null || customEvent.defaultPrevented) {
Expand Down Expand Up @@ -100,8 +96,7 @@ class Alert {

const transitionDuration = getTransitionDurationFromElement(element)

EventHandler
.one(element, TRANSITION_END, () => this._destroyElement(element))
EventHandler.one(element, TRANSITION_END, () => this._destroyElement(element))
emulateTransitionEnd(element, transitionDuration)
}

Expand Down
29 changes: 14 additions & 15 deletions js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ class Collapse {
}

_getDimension() {
const hasWidth = this._element.classList.contains(WIDTH)
return hasWidth ? WIDTH : HEIGHT
return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT
}

_getParent() {
Expand Down Expand Up @@ -319,21 +318,21 @@ class Collapse {
}

_addAriaAndCollapsedClass(element, triggerArray) {
if (element) {
const isOpen = element.classList.contains(CLASS_NAME_SHOW)

if (triggerArray.length) {
triggerArray.forEach(elem => {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED)
} else {
elem.classList.add(CLASS_NAME_COLLAPSED)
}
if (!element || !triggerArray.length) {
return
}

elem.setAttribute('aria-expanded', isOpen)
})
const isOpen = element.classList.contains(CLASS_NAME_SHOW)

triggerArray.forEach(elem => {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED)
} else {
elem.classList.add(CLASS_NAME_COLLAPSED)
}
}

elem.setAttribute('aria-expanded', isOpen)
})
}

// Static
Expand Down
16 changes: 8 additions & 8 deletions js/src/dom/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@ const mapData = (() => {
let id = 1
return {
set(element, key, data) {
if (typeof element.key === 'undefined') {
element.key = {
if (typeof element.bsKey === 'undefined') {
element.bsKey = {
key,
id
}
id++
}

storeData[element.key.id] = data
storeData[element.bsKey.id] = data
},
get(element, key) {
if (!element || typeof element.key === 'undefined') {
if (!element || typeof element.bsKey === 'undefined') {
return null
}

const keyProperties = element.key
const keyProperties = element.bsKey
if (keyProperties.key === key) {
return storeData[keyProperties.id]
}

return null
},
delete(element, key) {
if (typeof element.key === 'undefined') {
if (typeof element.bsKey === 'undefined') {
return
}

const keyProperties = element.key
const keyProperties = element.bsKey
if (keyProperties.key === key) {
delete storeData[keyProperties.id]
delete element.key
delete element.bsKey
}
}
}
Expand Down
50 changes: 23 additions & 27 deletions js/src/dom/event-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,13 @@ function removeHandler(element, events, typeEvent, handler, delegationSelector)
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
const storeElementEvent = events[typeEvent] || {}

Object.keys(storeElementEvent)
.forEach(handlerKey => {
if (handlerKey.indexOf(namespace) > -1) {
const event = storeElementEvent[handlerKey]
Object.keys(storeElementEvent).forEach(handlerKey => {
if (handlerKey.indexOf(namespace) > -1) {
const event = storeElementEvent[handlerKey]

removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
})
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
})
}

const EventHandler = {
Expand Down Expand Up @@ -247,23 +246,21 @@ const EventHandler = {
}

if (isNamespace) {
Object.keys(events)
.forEach(elementEvent => {
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1))
})
Object.keys(events).forEach(elementEvent => {
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1))
})
}

const storeElementEvent = events[typeEvent] || {}
Object.keys(storeElementEvent)
.forEach(keyHandlers => {
const handlerKey = keyHandlers.replace(stripUidRegex, '')
Object.keys(storeElementEvent).forEach(keyHandlers => {
const handlerKey = keyHandlers.replace(stripUidRegex, '')

if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
const event = storeElementEvent[keyHandlers]
if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
const event = storeElementEvent[keyHandlers]

removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
})
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
})
},

trigger(element, event, args) {
Expand Down Expand Up @@ -300,16 +297,15 @@ const EventHandler = {
})
}

// merge custom informations in our event
// merge custom information in our event
if (typeof args !== 'undefined') {
Object.keys(args)
.forEach(key => {
Object.defineProperty(evt, key, {
get() {
return args[key]
}
})
Object.keys(args).forEach(key => {
Object.defineProperty(evt, key, {
get() {
return args[key]
}
})
})
}

if (defaultPrevented) {
Expand Down
6 changes: 1 addition & 5 deletions js/src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,7 @@ class Dropdown {
...config
}

typeCheckConfig(
NAME,
config,
this.constructor.DefaultType
)
typeCheckConfig(NAME, config, this.constructor.DefaultType)

return config
}
Expand Down
6 changes: 1 addition & 5 deletions js/src/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,7 @@ class Toast {
...typeof config === 'object' && config ? config : {}
}

typeCheckConfig(
NAME,
config,
this.constructor.DefaultType
)
typeCheckConfig(NAME, config, this.constructor.DefaultType)

return config
}
Expand Down
6 changes: 1 addition & 5 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,11 +708,7 @@ class Tooltip {
config.content = config.content.toString()
}

typeCheckConfig(
NAME,
config,
this.constructor.DefaultType
)
typeCheckConfig(NAME, config, this.constructor.DefaultType)

if (config.sanitize) {
config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn)
Expand Down
29 changes: 14 additions & 15 deletions js/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,20 @@ const emulateTransitionEnd = (element, duration) => {
}

const typeCheckConfig = (componentName, config, configTypes) => {
Object.keys(configTypes)
.forEach(property => {
const expectedTypes = configTypes[property]
const value = config[property]
const valueType = value && isElement(value) ?
'element' :
toType(value)

if (!new RegExp(expectedTypes).test(valueType)) {
throw new Error(
`${componentName.toUpperCase()}: ` +
`Option "${property}" provided type "${valueType}" ` +
`but expected type "${expectedTypes}".`)
}
})
Object.keys(configTypes).forEach(property => {
const expectedTypes = configTypes[property]
const value = config[property]
const valueType = value && isElement(value) ?
'element' :
toType(value)

if (!new RegExp(expectedTypes).test(valueType)) {
throw new Error(
`${componentName.toUpperCase()}: ` +
`Option "${property}" provided type "${valueType}" ` +
`but expected type "${expectedTypes}".`)
}
})
}

const isVisible = element => {
Expand Down
14 changes: 7 additions & 7 deletions js/tests/unit/dom/data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Data', () => {
})

describe('setData', () => {
it('should set data in an element by adding a key attribute', () => {
it('should set data in an element by adding a bsKey attribute', () => {
fixtureEl.innerHTML = '<div></div>'

const div = fixtureEl.querySelector('div')
Expand All @@ -24,7 +24,7 @@ describe('Data', () => {
}

Data.setData(div, 'test', data)
expect(div.key).toBeDefined()
expect(div.bsKey).toBeDefined()
})

it('should change data if something is already stored', () => {
Expand All @@ -40,7 +40,7 @@ describe('Data', () => {
data.test = 'bsData2'
Data.setData(div, 'test', data)

expect(div.key).toBeDefined()
expect(div.bsKey).toBeDefined()
})
})

Expand Down Expand Up @@ -104,11 +104,11 @@ describe('Data', () => {

Data.setData(div, 'test', data)

expect(div.key).toBeDefined()
expect(div.bsKey).toBeDefined()

Data.removeData(div, 'test2')

expect(div.key).toBeDefined()
expect(div.bsKey).toBeDefined()
})

it('should remove data if something is stored', () => {
Expand All @@ -121,11 +121,11 @@ describe('Data', () => {

Data.setData(div, 'test', data)

expect(div.key).toBeDefined()
expect(div.bsKey).toBeDefined()

Data.removeData(div, 'test')

expect(div.key).toBeUndefined()
expect(div.bsKey).toBeUndefined()
})
})
})
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0347adb

Please sign in to comment.