diff options
| author | Priyansh <[email protected]> | 2021-10-06 14:40:59 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-06 14:40:59 -0400 |
| commit | 52cd86f8710f8049a744b5bcb9f4a7ce19114b6e (patch) | |
| tree | 8956dbd6f94ae25d273d496e64840ed30b6d88a5 /js/src/util | |
| parent | d065706ce4b439b5c77d9a68e708212e91cc4f0b (diff) | |
| parent | c331a150cdc2834f08bcf458cdb1b104cc510b67 (diff) | |
| download | bootstrap-52cd86f8710f8049a744b5bcb9f4a7ce19114b6e.tar.xz bootstrap-52cd86f8710f8049a744b5bcb9f4a7ce19114b6e.zip | |
Merge branch 'twbs:main' into main
Diffstat (limited to 'js/src/util')
| -rw-r--r-- | js/src/util/backdrop.js | 2 | ||||
| -rw-r--r-- | js/src/util/component-functions.js | 2 | ||||
| -rw-r--r-- | js/src/util/focustrap.js | 2 | ||||
| -rw-r--r-- | js/src/util/index.js | 14 | ||||
| -rw-r--r-- | js/src/util/sanitizer.js | 20 | ||||
| -rw-r--r-- | js/src/util/scrollbar.js | 6 |
6 files changed, 21 insertions, 25 deletions
diff --git a/js/src/util/backdrop.js b/js/src/util/backdrop.js index 80628c38d..e5ca0c860 100644 --- a/js/src/util/backdrop.js +++ b/js/src/util/backdrop.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/backdrop.js + * Bootstrap (v5.1.2): util/backdrop.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ diff --git a/js/src/util/component-functions.js b/js/src/util/component-functions.js index ff9d87ee6..c678ecadf 100644 --- a/js/src/util/component-functions.js +++ b/js/src/util/component-functions.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/component-functions.js + * Bootstrap (v5.1.2): util/component-functions.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ diff --git a/js/src/util/focustrap.js b/js/src/util/focustrap.js index d51942246..500a5b3bc 100644 --- a/js/src/util/focustrap.js +++ b/js/src/util/focustrap.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/focustrap.js + * Bootstrap (v5.1.2): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ diff --git a/js/src/util/index.js b/js/src/util/index.js index a4ad9c941..0ac4ed263 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -1,11 +1,11 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/index.js + * Bootstrap (v5.1.2): util/index.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -const MAX_UID = 1000000 +const MAX_UID = 1_000_000 const MILLISECONDS_MULTIPLIER = 1000 const TRANSITION_END = 'transitionend' @@ -15,7 +15,7 @@ const toType = obj => { return `${obj}` } - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase() + return Object.prototype.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase() } /** @@ -125,7 +125,7 @@ const getElement = obj => { } const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { + for (const property of Object.keys(configTypes)) { const expectedTypes = configTypes[property] const value = config[property] const valueType = value && isElement(value) ? 'element' : toType(value) @@ -135,7 +135,7 @@ const typeCheckConfig = (componentName, config, configTypes) => { `${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".` ) } - }) + } } const isVisible = element => { @@ -217,7 +217,9 @@ const onDOMContentLoaded = callback => { // add listener on the first call when the document is in loading state if (!DOMContentLoadedCallbacks.length) { document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()) + for (const callback of DOMContentLoadedCallbacks) { + callback() + } }) } diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index 17b925a8c..f5a8287cd 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/sanitizer.js + * Bootstrap (v5.1.2): util/sanitizer.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -43,16 +43,9 @@ const allowedAttribute = (attribute, allowedAttributeList) => { return true } - const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp) - // Check if a regular expression validates the attribute. - for (let i = 0, len = regExp.length; i < len; i++) { - if (regExp[i].test(attributeName)) { - return true - } - } - - return false + return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp) + .every(regex => regex.test(attributeName)) } export const DefaultAllowlist = { @@ -102,8 +95,7 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html') const elements = [].concat(...createdDocument.body.querySelectorAll('*')) - for (let i = 0, len = elements.length; i < len; i++) { - const element = elements[i] + for (const element of elements) { const elementName = element.nodeName.toLowerCase() if (!Object.keys(allowList).includes(elementName)) { @@ -115,11 +107,11 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { const attributeList = [].concat(...element.attributes) const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []) - attributeList.forEach(attribute => { + for (const attribute of attributeList) { if (!allowedAttribute(attribute, allowedAttributes)) { element.removeAttribute(attribute.nodeName) } - }) + } } return createdDocument.body.innerHTML diff --git a/js/src/util/scrollbar.js b/js/src/util/scrollbar.js index 73c28254e..f9a2d992d 100644 --- a/js/src/util/scrollbar.js +++ b/js/src/util/scrollbar.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/scrollBar.js + * Bootstrap (v5.1.2): util/scrollBar.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -85,7 +85,9 @@ class ScrollBarHelper { if (isElement(selector)) { callBack(selector) } else { - SelectorEngine.find(selector, this._element).forEach(callBack) + for (const sel of SelectorEngine.find(selector, this._element)) { + callBack(sel) + } } } |
