From 68e6de42ecca81aa7b46f6387ea4d057bd013a6e Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 19 Feb 2019 23:52:04 +0200 Subject: [PATCH] Use `Util.makeArray()`. --- js/src/carousel.js | 4 ++-- js/src/dom/polyfill.js | 4 ++-- js/src/dropdown.js | 2 +- js/src/index.js | 14 +++++++------- js/src/tools/sanitizer.js | 6 ++++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/js/src/carousel.js b/js/src/carousel.js index 9ff7c09e72..0536593141 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -320,7 +320,7 @@ class Carousel { } } - [].slice.call(SelectorEngine.find(Selector.ITEM_IMG, this._element)).forEach((itemImg) => { + Util.makeArray(SelectorEngine.find(Selector.ITEM_IMG, this._element)).forEach((itemImg) => { EventHandler.on(itemImg, Event.DRAG_START, (e) => e.preventDefault()) }) @@ -356,7 +356,7 @@ class Carousel { _getItemIndex(element) { this._items = element && element.parentNode - ? [].slice.call(SelectorEngine.find(Selector.ITEM, element.parentNode)) + ? Util.makeArray(SelectorEngine.find(Selector.ITEM, element.parentNode)) : [] return this._items.indexOf(element) diff --git a/js/src/dom/polyfill.js b/js/src/dom/polyfill.js index 8644dc7022..cbae0f668e 100644 --- a/js/src/dom/polyfill.js +++ b/js/src/dom/polyfill.js @@ -1,5 +1,3 @@ -import Util from '../util' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.3.1): dom/polyfill.js @@ -7,6 +5,8 @@ import Util from '../util' * -------------------------------------------------------------------------- */ +import Util from '../util' + /* istanbul ignore next */ const Polyfill = (() => { // MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 90006c66d3..2b517266ce 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -482,7 +482,7 @@ class Dropdown { return } - const items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS)) + const items = Util.makeArray(parent.querySelectorAll(Selector.VISIBLE_ITEMS)) if (!items.length) { return diff --git a/js/src/index.js b/js/src/index.js index aa35ed07b3..8a0044fe53 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -1,3 +1,10 @@ +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.3.1): index.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + import Alert from './alert' import Button from './button' import Carousel from './carousel' @@ -11,13 +18,6 @@ import Toast from './toast' import Tooltip from './tooltip' import Util from './util' -/** - * -------------------------------------------------------------------------- - * Bootstrap (v4.3.1): index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * -------------------------------------------------------------------------- - */ - export { Util, Alert, diff --git a/js/src/tools/sanitizer.js b/js/src/tools/sanitizer.js index ff78d06a73..3c1608fee8 100644 --- a/js/src/tools/sanitizer.js +++ b/js/src/tools/sanitizer.js @@ -5,6 +5,8 @@ * -------------------------------------------------------------------------- */ +import Util from '../util' + const uriAttrs = [ 'background', 'cite', @@ -101,7 +103,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { const domParser = new window.DOMParser() const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html') const whitelistKeys = Object.keys(whiteList) - const elements = [].slice.call(createdDocument.body.querySelectorAll('*')) + const elements = Util.makeArray(createdDocument.body.querySelectorAll('*')) for (let i = 0, len = elements.length; i < len; i++) { const el = elements[i] @@ -113,7 +115,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { continue } - const attributeList = [].slice.call(el.attributes) + const attributeList = Util.makeArray(el.attributes) const whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []) attributeList.forEach((attr) => {