Skip to content

Commit

Permalink
chore(merge main): patched commit → 548be2e
Browse files Browse the repository at this point in the history
  • Loading branch information
LE DIOURON Kevin committed Mar 8, 2021
1 parent 9754b74 commit bca3a33
Show file tree
Hide file tree
Showing 50 changed files with 2,954 additions and 1,233 deletions.
12 changes: 6 additions & 6 deletions .bundlewatch.config.json
Expand Up @@ -34,27 +34,27 @@
},
{
"path": "./dist/js/boosted.bundle.js",
"maxSize": "45.3 kB"
"maxSize": "46.7 kB"
},
{
"path": "./dist/js/boosted.bundle.min.js",
"maxSize": "22.9 kB"
"maxSize": "23.6 kB"
},
{
"path": "./dist/js/boosted.esm.js",
"maxSize": "27.4 kB"
"maxSize": "28.8 kB"
},
{
"path": "./dist/js/boosted.esm.min.js",
"maxSize": "18.4 kB"
"maxSize": "19.1 kB"
},
{
"path": "./dist/js/boosted.js",
"maxSize": "28.1 kB"
"maxSize": "29.6 kB"
},
{
"path": "./dist/js/boosted.min.js",
"maxSize": "16 kB"
"maxSize": "16.6 kB"
}
],
"ci": {
Expand Down
2 changes: 1 addition & 1 deletion .eslintignore
@@ -1,6 +1,6 @@
**/*.min.js
**/dist/
**/vendor/
/_gh_pages/
/_site/
/js/coverage/
/site/static/sw.js
2 changes: 1 addition & 1 deletion .github/workflows/percy.yml
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Percy Test
uses: percy/snapshot-action@v0.1.2
with:
build-directory: "_gh_pages/"
build-directory: "_site/"
flags: "--snapshot-files ./docs/5.0/guidelines/**/*.html,./docs/5.0/examples/cheatsheet/index.html,./docs/5.0/examples/cheatsheet-rtl/index.html"
verbose: true
env:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,5 +1,5 @@
# Ignore docs files
/_gh_pages/
/_site/
# Hugo resources folder
/resources/

Expand Down
2 changes: 1 addition & 1 deletion .stylelintignore
@@ -1,5 +1,5 @@
**/*.min.css
**/dist/
**/vendor/
/_gh_pages/
/_site/
/js/coverage/
3 changes: 2 additions & 1 deletion build/build-plugins.js
Expand Up @@ -35,6 +35,7 @@ const bsPlugins = {
Collapse: path.resolve(__dirname, '../js/src/collapse.js'),
Dropdown: path.resolve(__dirname, '../js/src/dropdown.js'),
Modal: path.resolve(__dirname, '../js/src/modal.js'),
OffCanvas: path.resolve(__dirname, '../js/src/offcanvas.js'),
Popover: path.resolve(__dirname, '../js/src/popover.js'),
ScrollSpy: path.resolve(__dirname, '../js/src/scrollspy.js'),
Tab: path.resolve(__dirname, '../js/src/tab.js'),
Expand Down Expand Up @@ -71,7 +72,7 @@ const getConfigByPluginKey = pluginKey => {
}
}

if (pluginKey === 'Alert' || pluginKey === 'Tab') {
if (pluginKey === 'Alert' || pluginKey === 'Tab' || pluginKey === 'OffCanvas') {
return defaultPluginConfig
}

Expand Down
2 changes: 1 addition & 1 deletion build/change-version.js
Expand Up @@ -90,7 +90,7 @@ function main(args) {
const newVersion = args[1]
const EXCLUDED_DIRS = new Set([
'.git',
'_gh_pages',
'_site',
'node_modules',
'resources'
])
Expand Down
2 changes: 1 addition & 1 deletion build/ship.sh
Expand Up @@ -47,7 +47,7 @@ npm run release
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/
cp -rf _site/. ../bs-docs/
printf "\nDone!\n"

printf "\n%s=======================================================%s" "$green" "$end"
Expand Down
2 changes: 1 addition & 1 deletion build/vnu-jar.js
Expand Up @@ -51,7 +51,7 @@ childProcess.exec('java -version', (error, stdout, stderr) => {
'--no-langdetect',
'--Werror',
`--filterpattern "${ignores}"`,
'_gh_pages/',
'_site/',
'js/tests/'
]

Expand Down
2 changes: 1 addition & 1 deletion build/zip-examples.js
Expand Up @@ -16,7 +16,7 @@ const pkg = require('../package.json')

const versionShort = pkg.config.version_short
const distFolder = `boosted-${pkg.version}-examples`
const rootDocsDir = '_gh_pages'
const rootDocsDir = '_site'
const docsDir = `${rootDocsDir}/docs/${versionShort}/`

// these are the files we need in the examples
Expand Down
2 changes: 1 addition & 1 deletion config.yml
Expand Up @@ -20,7 +20,7 @@ enableRobotsTXT: true
metaDataFormat: "yaml"
disableKinds: ["404", "taxonomy", "taxonomyTerm", "RSS"]

publishDir: "_gh_pages"
publishDir: "_site"

module:
mounts:
Expand Down
2 changes: 2 additions & 0 deletions js/index.esm.js
Expand Up @@ -11,6 +11,7 @@ import Carousel from './src/carousel'
import Collapse from './src/collapse'
import Dropdown from './src/dropdown'
import Modal from './src/modal'
import OffCanvas from './src/offcanvas'
import Popover from './src/popover'
import ScrollSpy from './src/scrollspy'
import Tab from './src/tab'
Expand All @@ -25,6 +26,7 @@ export {
Collapse,
Dropdown,
Modal,
OffCanvas,
Popover,
ScrollSpy,
Tab,
Expand Down
2 changes: 2 additions & 0 deletions js/index.umd.js
Expand Up @@ -11,6 +11,7 @@ import Carousel from './src/carousel'
import Collapse from './src/collapse'
import Dropdown from './src/dropdown'
import Modal from './src/modal'
import OffCanvas from './src/offcanvas'
import Popover from './src/popover'
import ScrollSpy from './src/scrollspy'
import Tab from './src/tab'
Expand All @@ -25,6 +26,7 @@ export default {
Collapse,
Dropdown,
Modal,
OffCanvas,
Popover,
ScrollSpy,
Tab,
Expand Down
2 changes: 1 addition & 1 deletion js/src/alert.js
Expand Up @@ -98,7 +98,7 @@ class Alert extends BaseComponent {

static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY)
let data = Data.get(this, DATA_KEY)

if (!data) {
data = new Alert(this)
Expand Down
6 changes: 3 additions & 3 deletions js/src/base-component.js
Expand Up @@ -24,18 +24,18 @@ class BaseComponent {
}

this._element = element
Data.setData(this._element, this.constructor.DATA_KEY, this)
Data.set(this._element, this.constructor.DATA_KEY, this)
}

dispose() {
Data.removeData(this._element, this.constructor.DATA_KEY)
Data.remove(this._element, this.constructor.DATA_KEY)
this._element = null
}

/** Static */

static getInstance(element) {
return Data.getData(element, this.DATA_KEY)
return Data.get(element, this.DATA_KEY)
}

static get VERSION() {
Expand Down
4 changes: 2 additions & 2 deletions js/src/button.js
Expand Up @@ -51,7 +51,7 @@ class Button extends BaseComponent {

static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY)
let data = Data.get(this, DATA_KEY)

if (!data) {
data = new Button(this)
Expand All @@ -75,7 +75,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {

const button = event.target.closest(SELECTOR_DATA_TOGGLE)

let data = Data.getData(button, DATA_KEY)
let data = Data.get(button, DATA_KEY)
if (!data) {
data = new Button(button)
}
Expand Down
6 changes: 3 additions & 3 deletions js/src/carousel.js
Expand Up @@ -609,7 +609,7 @@ class Carousel extends BaseComponent {
// Static

static carouselInterface(element, config) {
let data = Data.getData(element, DATA_KEY)
let data = Data.get(element, DATA_KEY)
let _config = {
...Default,
...Manipulator.getDataAttributes(element)
Expand Down Expand Up @@ -668,7 +668,7 @@ class Carousel extends BaseComponent {
Carousel.carouselInterface(target, config)

if (slideIndex) {
Data.getData(target, DATA_KEY).to(slideIndex)
Data.get(target, DATA_KEY).to(slideIndex)
}

event.preventDefault()
Expand All @@ -687,7 +687,7 @@ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)

for (let i = 0, len = carousels.length; i < len; i++) {
Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY))
Carousel.carouselInterface(carousels[i], Data.get(carousels[i], DATA_KEY))
}
})

Expand Down
8 changes: 4 additions & 4 deletions js/src/collapse.js
Expand Up @@ -147,7 +147,7 @@ class Collapse extends BaseComponent {
const container = SelectorEngine.findOne(this._selector)
if (actives) {
const tempActiveData = actives.find(elem => container !== elem)
activesData = tempActiveData ? Data.getData(tempActiveData, DATA_KEY) : null
activesData = tempActiveData ? Data.get(tempActiveData, DATA_KEY) : null

if (activesData && activesData._isTransitioning) {
return
Expand All @@ -166,7 +166,7 @@ class Collapse extends BaseComponent {
}

if (!activesData) {
Data.setData(elemActive, DATA_KEY, null)
Data.set(elemActive, DATA_KEY, null)
}
})
}
Expand Down Expand Up @@ -332,7 +332,7 @@ class Collapse extends BaseComponent {
// Static

static collapseInterface(element, config) {
let data = Data.getData(element, DATA_KEY)
let data = Data.get(element, DATA_KEY)
const _config = {
...Default,
...Manipulator.getDataAttributes(element),
Expand Down Expand Up @@ -380,7 +380,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
const selectorElements = SelectorEngine.find(selector)

selectorElements.forEach(element => {
const data = Data.getData(element, DATA_KEY)
const data = Data.get(element, DATA_KEY)
let config
if (data) {
// update parent attribute
Expand Down
80 changes: 35 additions & 45 deletions js/src/dom/data.js
Expand Up @@ -11,57 +11,47 @@
* ------------------------------------------------------------------------
*/

const mapData = (() => {
const storeData = {}
let id = 1
return {
set(element, key, data) {
if (typeof element.bsKey === 'undefined') {
element.bsKey = {
key,
id
}
id++
}
const elementMap = new Map()

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

const keyProperties = element.bsKey
if (keyProperties.key === key) {
return storeData[keyProperties.id]
}
export default {
set(element, key, instance) {
if (!elementMap.has(element)) {
elementMap.set(element, new Map())
}

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

const keyProperties = element.bsKey
if (keyProperties.key === key) {
delete storeData[keyProperties.id]
delete element.bsKey
}
// make it clear we only want one instance per element
// can be removed later when multiple key/instances are fine to be used
if (!instanceMap.has(key) && instanceMap.size !== 0) {
// eslint-disable-next-line no-console
console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`)
return
}
}
})()

const Data = {
setData(instance, key, data) {
mapData.set(instance, key, data)
instanceMap.set(key, instance)
},
getData(instance, key) {
return mapData.get(instance, key)

get(element, key) {
if (elementMap.has(element)) {
return elementMap.get(element).get(key) || null
}

return null
},
removeData(instance, key) {
mapData.delete(instance, key)

remove(element, key) {
if (!elementMap.has(element)) {
return
}

const instanceMap = elementMap.get(element)

instanceMap.delete(key)

// free up element references if there are no instances left for an element
if (instanceMap.size === 0) {
elementMap.delete(element)
}
}
}

export default Data

0 comments on commit bca3a33

Please sign in to comment.