Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
26d86fce
Unverified
Commit
26d86fce
authored
4 years ago
by
Johann-S
Committed by
GitHub
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
fix: remove make array util function (#30430)
parent
98c45986
main
cleanup-floating-forms
cssvar-function
dependabot/npm_and_yarn/stylelint-and-stylelint-config-twbs-bootstrap-15.3.0
extend-snippets
feat/data-target
floating-always-visible
floating-labels-icons
fod-main-banner
form-controls-with-icons
github/fork/719media/patch-13
github/fork/719media/patch-14
github/fork/719media/patch-9
github/fork/ChellyAhmed/fix-typo-reboot.md
github/fork/ChellyAhmed/offcanvas-scroll-back
github/fork/CtrlAltLilith/main
github/fork/Elysiome/offcanvas-optional-window-resizing
github/fork/JanSargsyan/main
github/fork/LunicLynx/support-different-line-height-for-buttons
github/fork/Psixodelik/main
github/fork/Ronid1/ronid1/offcanvas_static_backdrop
github/fork/RyanBerliner/tooltip-accessibility
github/fork/SantiagoPVazquez/Feature-default-border-bottom-to-dropdown-item
github/fork/Sir-Genius/utils
github/fork/Sumit-Singh-8/main
github/fork/Viktor-VERA2020/offcanvas-slide
github/fork/Zivangu9/input-group-for-form-control-plaintext
github/fork/alpadev/alpadev/call-dispose-on-component-reinstantiation
github/fork/astagi/fix/tree-shake-modules
github/fork/compnerd/dark-accordion-icon
github/fork/derSascha/dropdown-dont-close-on-input-click
github/fork/dev-ph1l/main
github/fork/donquixote/issue-33861-utl-mixin
github/fork/florianlacreuse/mixin-make-row-gutter-y
github/fork/gregorw/main
github/fork/iteggmbh/transitionend-dispose-race
github/fork/jdelStrother/patch-1
github/fork/jonnysp/form-floating
github/fork/jonnysp/independent-offcanvas
github/fork/jonnysp/theme-dark-on-card-and-modal-fix
github/fork/josefdlange/floating-label-placeholder-opacity
github/fork/julien-deramond/enhance-change-version.js
github/fork/julien-deramond/main-jd-fix-offset-content
github/fork/julien-deramond/main-jd-issue-with-utitlies
github/fork/julien-deramond/main-xmr-pa11y-ci-jd-add-hideElements
github/fork/kyletsang/fix-tooltip-padding
github/fork/lacutah/CheckboxCenteringDocumentation
github/fork/lekoala/patch-3
github/fork/louismaximepiton/main-kld-lmp-collapse-proposal
github/fork/louismaximepiton/main-lmp-card-inner-border-radius-fix
github/fork/louismaximepiton/main-lmp-carousel-multiple-images
github/fork/louismaximepiton/main-lmp-css-var-init
github/fork/louismaximepiton/main-lmp-disabled-floating-label-fix
github/fork/louismaximepiton/main-lmp-input-range-fix
github/fork/louismaximepiton/main-lmp-shift-color
github/fork/louismaximepiton/main-lmp-table-active-tr-fix
github/fork/maciek-szn/switch
github/fork/michael-roth/feature/19964-multiple-tab-targets
github/fork/mistic100/dom-utils
github/fork/nkdas91/accordion
github/fork/nstungcom/fix-missing-modal-open-class
github/fork/oraliahdz/animation-utilities
github/fork/pine3ree/patch-7
github/fork/pouwerkerk/unindent-scss-docs-shortcode
github/fork/smares/smares-no-scolling-on-modal-close
github/fork/tgm-git/patch-1
gs-forms
gs-toasts-with-animated-progress-bar
gs/add-history-helper
gs/change-version-dir-on-docs
gs/data-must-set-onlu-one-instance
gs/docs/fix-drop-down-error
gs/event-handler-2
gs/make-docs-js-build
gs/make-simple-attribute-toggler
gs/popover-fix-doc
gs/provide-steConfig-method
gs/scrollspy-smoothscroll-option-use-browser-history
gs/streamline-jqueryInterface
gs/support-drop-down-in-navbar
gs/test-js-generic-trigger
gs/try-web-components
gs/tweak-collapse-js-selector
gs/use-event-handler-in-cocmponent
gs/use-rollup-replace-for-version
jo-docs-thanks-page
jo-ssr-friendly
logical-props-spacing-utils
main-fod-disabled-form-check-label
main-fod-nested-accordion
main-fod-simpler-table-structure
main-fod-table-separator
main-fod-utilities-contrast
main-jd-abbr-title
main-jd-add-chips
main-jd-add-doc-for-sass-custom-colors
main-jd-add-enable-host-to-handle-web-components
main-jd-browserstack-fine-tune
main-jd-browserstack-updates
main-jd-docs-consistent-usage-of-css-sections-step-2
main-jd-fix-docs-headers-in-white
main-jd-fix-highlight-docs-border-radius
main-jd-fix-placeholder-color-background-params-for-img-markup
main-jd-glossary-experiment
main-jd-postcss-drop-empty-css-vars
main-jd-proto-doc-astro
main-jd-skip-navigation-component
main-jd-stackblitz-for-examples
main-jd-upgrade-browserlistrc
main-jd-use-host
main-lmp-dark-theme-customization
main-lmp-handle-scroll-target
main-lmp-tab-fix
main-mc-opensearch
main-xmr-bundlewatch-action
main-xmr-eslint-plugin-compat
main-xmr-hugo-docs-vendor
main-xmr-hugo-rm-ver
main-xmr-linkinator-prod
main-xmr-min-mangle
main-xmr-pa11y-ci
more-darkmode-examples
nested-dropdowns
patrickhlauke-issue37428
patrickhlauke-use-of-color-tweaks
pr/34102
pr/37590
previous-next-docs-links
sticky-thead
utilities-functions-mixin
v530-dev
v6-postcss-custom-media
v6-spinner-dots
v6/gs/use-floating-ui-in-place-of-popper
xmr/dev
xmr/docs-png
xmr/docs-svgs
xmr/hugo-reorg-files
xmr/js-2
xmr/markdownlint
xmr/prepare-530-alpha2
xmr/xo
v5.3.0-alpha1
v5.2.3
v5.2.2
v5.2.1
v5.2.0
v5.2.0-beta1
v5.1.3
v5.1.2
v5.1.1
v5.1.0
v5.0.2
v5.0.1
v5.0.0
v5.0.0-beta3
v5.0.0-beta2
v5.0.0-beta1
v5.0.0-alpha3
v5.0.0-alpha2
v5.0.0-alpha1
1 merge request
!31948
Examples/Floating-labels: fix bad behavior with autofill
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
js/src/carousel.js
+4
-4
js/src/carousel.js
js/src/collapse.js
+8
-8
js/src/collapse.js
js/src/dom/selector-engine.js
+4
-5
js/src/dom/selector-engine.js
js/src/dropdown.js
+6
-6
js/src/dropdown.js
js/src/modal.js
+4
-5
js/src/modal.js
js/src/scrollspy.js
+3
-4
js/src/scrollspy.js
js/src/tab.js
+2
-3
js/src/tab.js
js/src/tooltip.js
+2
-3
js/src/tooltip.js
js/src/util/index.js
+0
-9
js/src/util/index.js
js/src/util/sanitizer.js
+2
-4
js/src/util/sanitizer.js
js/tests/unit/alert.spec.js
+5
-5
js/tests/unit/alert.spec.js
js/tests/unit/collapse.spec.js
+1
-2
js/tests/unit/collapse.spec.js
js/tests/unit/dom/selector-engine.spec.js
+5
-6
js/tests/unit/dom/selector-engine.spec.js
js/tests/unit/modal.spec.js
+4
-5
js/tests/unit/modal.spec.js
js/tests/unit/popover.spec.js
+1
-2
js/tests/unit/popover.spec.js
js/tests/unit/tooltip.spec.js
+2
-4
js/tests/unit/tooltip.spec.js
js/tests/unit/util/index.spec.js
+0
-14
js/tests/unit/util/index.spec.js
with
53 additions
and
89 deletions
+53
-89
js/src/carousel.js
+
4
-
4
View file @
26d86fce
...
...
@@ -12,7 +12,6 @@ import {
getElementFromSelector
,
getTransitionDurationFromElement
,
isVisible
,
makeArray
,
reflow
,
triggerTransitionEnd
,
typeCheckConfig
...
...
@@ -322,7 +321,7 @@ class Carousel {
}
}
makeArray
(
SelectorEngine
.
find
(
SELECTOR_ITEM_IMG
,
this
.
_element
)
)
.
forEach
(
itemImg
=>
{
SelectorEngine
.
find
(
SELECTOR_ITEM_IMG
,
this
.
_element
).
forEach
(
itemImg
=>
{
EventHandler
.
on
(
itemImg
,
EVENT_DRAG_START
,
e
=>
e
.
preventDefault
())
})
...
...
@@ -358,7 +357,7 @@ class Carousel {
_getItemIndex
(
element
)
{
this
.
_items
=
element
&&
element
.
parentNode
?
makeArray
(
SelectorEngine
.
find
(
SELECTOR_ITEM
,
element
.
parentNode
)
)
:
SelectorEngine
.
find
(
SELECTOR_ITEM
,
element
.
parentNode
)
:
[]
return
this
.
_items
.
indexOf
(
element
)
...
...
@@ -601,7 +600,8 @@ EventHandler
.
on
(
document
,
EVENT_CLICK_DATA_API
,
SELECTOR_DATA_SLIDE
,
Carousel
.
dataApiClickHandler
)
EventHandler
.
on
(
window
,
EVENT_LOAD_DATA_API
,
()
=>
{
const
carousels
=
makeArray
(
SelectorEngine
.
find
(
SELECTOR_DATA_RIDE
))
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
))
}
...
...
This diff is collapsed.
Click to expand it.
js/src/collapse.js
+
8
-
8
View file @
26d86fce
...
...
@@ -13,7 +13,6 @@ import {
getElementFromSelector
,
getTransitionDurationFromElement
,
isElement
,
makeArray
,
reflow
,
typeCheckConfig
}
from
'
./util/index
'
...
...
@@ -72,16 +71,17 @@ class Collapse {
this
.
_isTransitioning
=
false
this
.
_element
=
element
this
.
_config
=
this
.
_getConfig
(
config
)
this
.
_triggerArray
=
makeArray
(
SelectorEngine
.
find
(
this
.
_triggerArray
=
SelectorEngine
.
find
(
`
${
SELECTOR_DATA_TOGGLE
}
[href="#
${
element
.
id
}
"],`
+
`
${
SELECTOR_DATA_TOGGLE
}
[data-target="#
${
element
.
id
}
"]`
))
)
const
toggleList
=
SelectorEngine
.
find
(
SELECTOR_DATA_TOGGLE
)
const
toggleList
=
makeArray
(
SelectorEngine
.
find
(
SELECTOR_DATA_TOGGLE
))
for
(
let
i
=
0
,
len
=
toggleList
.
length
;
i
<
len
;
i
++
)
{
const
elem
=
toggleList
[
i
]
const
selector
=
getSelectorFromElement
(
elem
)
const
filterElement
=
makeArray
(
SelectorEngine
.
find
(
selector
)
)
const
filterElement
=
SelectorEngine
.
find
(
selector
)
.
filter
(
foundElem
=>
foundElem
===
element
)
if
(
selector
!==
null
&&
filterElement
.
length
)
{
...
...
@@ -133,7 +133,7 @@ class Collapse {
let
activesData
if
(
this
.
_parent
)
{
actives
=
makeArray
(
SelectorEngine
.
find
(
SELECTOR_ACTIVES
,
this
.
_parent
)
)
actives
=
SelectorEngine
.
find
(
SELECTOR_ACTIVES
,
this
.
_parent
)
.
filter
(
elem
=>
{
if
(
typeof
this
.
_config
.
parent
===
'
string
'
)
{
return
elem
.
getAttribute
(
'
data-parent
'
)
===
this
.
_config
.
parent
...
...
@@ -307,7 +307,7 @@ class Collapse {
const
selector
=
`
${
SELECTOR_DATA_TOGGLE
}
[data-parent="
${
parent
}
"]`
makeArray
(
SelectorEngine
.
find
(
selector
,
parent
)
)
SelectorEngine
.
find
(
selector
,
parent
)
.
forEach
(
element
=>
{
const
selected
=
getElementFromSelector
(
element
)
...
...
@@ -390,7 +390,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
const
triggerData
=
Manipulator
.
getDataAttributes
(
this
)
const
selector
=
getSelectorFromElement
(
this
)
const
selectorElements
=
makeArray
(
SelectorEngine
.
find
(
selector
)
)
const
selectorElements
=
SelectorEngine
.
find
(
selector
)
selectorElements
.
forEach
(
element
=>
{
const
data
=
Data
.
getData
(
element
,
DATA_KEY
)
...
...
This diff is collapsed.
Click to expand it.
js/src/dom/selector-engine.js
+
4
-
5
View file @
26d86fce
...
...
@@ -6,7 +6,6 @@
*/
import
{
find
as
findFn
,
findOne
}
from
'
./polyfill
'
import
{
makeArray
}
from
'
../util/index
'
/**
* ------------------------------------------------------------------------
...
...
@@ -22,7 +21,7 @@ const SelectorEngine = {
},
find
(
selector
,
element
=
document
.
documentElement
)
{
return
findFn
.
call
(
element
,
selector
)
return
[].
concat
(...
findFn
.
call
(
element
,
selector
)
)
},
findOne
(
selector
,
element
=
document
.
documentElement
)
{
...
...
@@ -30,9 +29,9 @@ const SelectorEngine = {
},
children
(
element
,
selector
)
{
const
children
=
makeArray
(
element
.
children
)
const
children
=
[].
concat
(...
element
.
children
)
return
children
.
filter
(
child
=>
t
hi
s
.
matches
(
child
,
selector
))
return
children
.
filter
(
child
=>
c
hi
ld
.
matches
(
selector
))
},
parents
(
element
,
selector
)
{
...
...
@@ -59,7 +58,7 @@ const SelectorEngine = {
let
previous
=
element
.
previousElementSibling
while
(
previous
)
{
if
(
thi
s
.
matches
(
previous
,
selector
))
{
if
(
previou
s
.
matches
(
selector
))
{
return
[
previous
]
}
...
...
This diff is collapsed.
Click to expand it.
js/src/dropdown.js
+
6
-
6
View file @
26d86fce
...
...
@@ -10,7 +10,6 @@ import {
getElementFromSelector
,
isElement
,
isVisible
,
makeArray
,
noop
,
typeCheckConfig
}
from
'
./util/index
'
...
...
@@ -190,8 +189,8 @@ class Dropdown {
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if
(
'
ontouchstart
'
in
document
.
documentElement
&&
!
makeArray
(
SelectorEngine
.
closest
(
parent
,
SELECTOR_NAVBAR_NAV
))
.
length
)
{
makeArray
(
document
.
body
.
children
)
!
SelectorEngine
.
closest
(
parent
,
SELECTOR_NAVBAR_NAV
))
{
[].
concat
(...
document
.
body
.
children
)
.
forEach
(
elem
=>
EventHandler
.
on
(
elem
,
'
mouseover
'
,
null
,
noop
()))
}
...
...
@@ -378,7 +377,8 @@ class Dropdown {
return
}
const
toggles
=
makeArray
(
SelectorEngine
.
find
(
SELECTOR_DATA_TOGGLE
))
const
toggles
=
SelectorEngine
.
find
(
SELECTOR_DATA_TOGGLE
)
for
(
let
i
=
0
,
len
=
toggles
.
length
;
i
<
len
;
i
++
)
{
const
parent
=
Dropdown
.
getParentFromElement
(
toggles
[
i
])
const
context
=
Data
.
getData
(
toggles
[
i
],
DATA_KEY
)
...
...
@@ -414,7 +414,7 @@ class Dropdown {
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if
(
'
ontouchstart
'
in
document
.
documentElement
)
{
makeArray
(
document
.
body
.
children
)
[].
concat
(...
document
.
body
.
children
)
.
forEach
(
elem
=>
EventHandler
.
off
(
elem
,
'
mouseover
'
,
null
,
noop
()))
}
...
...
@@ -472,7 +472,7 @@ class Dropdown {
return
}
const
items
=
makeArray
(
SelectorEngine
.
find
(
SELECTOR_VISIBLE_ITEMS
,
parent
)
)
const
items
=
SelectorEngine
.
find
(
SELECTOR_VISIBLE_ITEMS
,
parent
)
.
filter
(
isVisible
)
if
(
!
items
.
length
)
{
...
...
This diff is collapsed.
Click to expand it.
js/src/modal.js
+
4
-
5
View file @
26d86fce
...
...
@@ -12,7 +12,6 @@ import {
getElementFromSelector
,
getTransitionDurationFromElement
,
isVisible
,
makeArray
,
reflow
,
typeCheckConfig
}
from
'
./util/index
'
...
...
@@ -456,7 +455,7 @@ class Modal {
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
// Adjust fixed content padding
makeArray
(
SelectorEngine
.
find
(
SELECTOR_FIXED_CONTENT
)
)
SelectorEngine
.
find
(
SELECTOR_FIXED_CONTENT
)
.
forEach
(
element
=>
{
const
actualPadding
=
element
.
style
.
paddingRight
const
calculatedPadding
=
window
.
getComputedStyle
(
element
)[
'
padding-right
'
]
...
...
@@ -465,7 +464,7 @@ class Modal {
})
// Adjust sticky content margin
makeArray
(
SelectorEngine
.
find
(
SELECTOR_STICKY_CONTENT
)
)
SelectorEngine
.
find
(
SELECTOR_STICKY_CONTENT
)
.
forEach
(
element
=>
{
const
actualMargin
=
element
.
style
.
marginRight
const
calculatedMargin
=
window
.
getComputedStyle
(
element
)[
'
margin-right
'
]
...
...
@@ -486,7 +485,7 @@ class Modal {
_resetScrollbar
()
{
// Restore fixed content padding
makeArray
(
SelectorEngine
.
find
(
SELECTOR_FIXED_CONTENT
)
)
SelectorEngine
.
find
(
SELECTOR_FIXED_CONTENT
)
.
forEach
(
element
=>
{
const
padding
=
Manipulator
.
getDataAttribute
(
element
,
'
padding-right
'
)
if
(
typeof
padding
!==
'
undefined
'
)
{
...
...
@@ -496,7 +495,7 @@ class Modal {
})
// Restore sticky content and navbar-toggler margin
makeArray
(
SelectorEngine
.
find
(
`
${
SELECTOR_STICKY_CONTENT
}
`
)
)
SelectorEngine
.
find
(
`
${
SELECTOR_STICKY_CONTENT
}
`
)
.
forEach
(
element
=>
{
const
margin
=
Manipulator
.
getDataAttribute
(
element
,
'
margin-right
'
)
if
(
typeof
margin
!==
'
undefined
'
)
{
...
...
This diff is collapsed.
Click to expand it.
js/src/scrollspy.js
+
3
-
4
View file @
26d86fce
...
...
@@ -9,7 +9,6 @@ import {
getjQuery
,
getSelectorFromElement
,
getUID
,
makeArray
,
typeCheckConfig
}
from
'
./util/index
'
import
Data
from
'
./dom/data
'
...
...
@@ -116,7 +115,7 @@ class ScrollSpy {
this
.
_scrollHeight
=
this
.
_getScrollHeight
()
const
targets
=
makeArray
(
SelectorEngine
.
find
(
this
.
_selector
)
)
const
targets
=
SelectorEngine
.
find
(
this
.
_selector
)
targets
.
map
(
element
=>
{
...
...
@@ -286,7 +285,7 @@ class ScrollSpy {
}
_clear
()
{
makeArray
(
SelectorEngine
.
find
(
this
.
_selector
)
)
SelectorEngine
.
find
(
this
.
_selector
)
.
filter
(
node
=>
node
.
classList
.
contains
(
CLASS_NAME_ACTIVE
))
.
forEach
(
node
=>
node
.
classList
.
remove
(
CLASS_NAME_ACTIVE
))
}
...
...
@@ -324,7 +323,7 @@ class ScrollSpy {
*/
EventHandler
.
on
(
window
,
EVENT_LOAD_DATA_API
,
()
=>
{
makeArray
(
SelectorEngine
.
find
(
SELECTOR_DATA_SPY
)
)
SelectorEngine
.
find
(
SELECTOR_DATA_SPY
)
.
forEach
(
spy
=>
new
ScrollSpy
(
spy
,
Manipulator
.
getDataAttributes
(
spy
)))
})
...
...
This diff is collapsed.
Click to expand it.
js/src/tab.js
+
2
-
3
View file @
26d86fce
...
...
@@ -11,7 +11,6 @@ import {
emulateTransitionEnd
,
getElementFromSelector
,
getTransitionDurationFromElement
,
makeArray
,
reflow
}
from
'
./util/index
'
import
Data
from
'
./dom/data
'
...
...
@@ -85,7 +84,7 @@ class Tab {
if
(
listElement
)
{
const
itemSelector
=
listElement
.
nodeName
===
'
UL
'
||
listElement
.
nodeName
===
'
OL
'
?
SELECTOR_ACTIVE_UL
:
SELECTOR_ACTIVE
previous
=
makeArray
(
SelectorEngine
.
find
(
itemSelector
,
listElement
)
)
previous
=
SelectorEngine
.
find
(
itemSelector
,
listElement
)
previous
=
previous
[
previous
.
length
-
1
]
}
...
...
@@ -190,7 +189,7 @@ class Tab {
const
dropdownElement
=
SelectorEngine
.
closest
(
element
,
SELECTOR_DROPDOWN
)
if
(
dropdownElement
)
{
makeArray
(
SelectorEngine
.
find
(
SELECTOR_DROPDOWN_TOGGLE
)
)
SelectorEngine
.
find
(
SELECTOR_DROPDOWN_TOGGLE
)
.
forEach
(
dropdown
=>
dropdown
.
classList
.
add
(
CLASS_NAME_ACTIVE
))
}
...
...
This diff is collapsed.
Click to expand it.
js/src/tooltip.js
+
2
-
3
View file @
26d86fce
...
...
@@ -13,7 +13,6 @@ import {
getTransitionDurationFromElement
,
getUID
,
isElement
,
makeArray
,
noop
,
typeCheckConfig
}
from
'
./util/index
'
...
...
@@ -301,7 +300,7 @@ class Tooltip {
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if
(
'
ontouchstart
'
in
document
.
documentElement
)
{
makeArray
(
document
.
body
.
children
).
forEach
(
element
=>
{
[].
concat
(...
document
.
body
.
children
).
forEach
(
element
=>
{
EventHandler
.
on
(
element
,
'
mouseover
'
,
noop
())
})
}
...
...
@@ -354,7 +353,7 @@ class Tooltip {
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if
(
'
ontouchstart
'
in
document
.
documentElement
)
{
makeArray
(
document
.
body
.
children
)
[].
concat
(...
document
.
body
.
children
)
.
forEach
(
element
=>
EventHandler
.
off
(
element
,
'
mouseover
'
,
noop
))
}
...
...
This diff is collapsed.
Click to expand it.
js/src/util/index.js
+
0
-
9
View file @
26d86fce
...
...
@@ -127,14 +127,6 @@ const typeCheckConfig = (componentName, config, configTypes) => {
})
}
const
makeArray
=
nodeList
=>
{
if
(
!
nodeList
)
{
return
[]
}
return
[].
slice
.
call
(
nodeList
)
}
const
isVisible
=
element
=>
{
if
(
!
element
)
{
return
false
...
...
@@ -200,7 +192,6 @@ export {
isElement
,
emulateTransitionEnd
,
typeCheckConfig
,
makeArray
,
isVisible
,
findShadowRoot
,
noop
,
...
...
This diff is collapsed.
Click to expand it.
js/src/util/sanitizer.js
+
2
-
4
View file @
26d86fce
...
...
@@ -5,8 +5,6 @@
* --------------------------------------------------------------------------
*/
import
{
makeArray
}
from
'
./index
'
const
uriAttrs
=
[
'
background
'
,
'
cite
'
,
...
...
@@ -103,7 +101,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
=
makeArray
(
createdDocument
.
body
.
querySelectorAll
(
'
*
'
))
const
elements
=
[].
concat
(...
createdDocument
.
body
.
querySelectorAll
(
'
*
'
))
for
(
let
i
=
0
,
len
=
elements
.
length
;
i
<
len
;
i
++
)
{
const
el
=
elements
[
i
]
...
...
@@ -115,7 +113,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
continue
}
const
attributeList
=
makeArray
(
el
.
attributes
)
const
attributeList
=
[].
concat
(...
el
.
attributes
)
const
whitelistedAttributes
=
[].
concat
(
whiteList
[
'
*
'
]
||
[],
whiteList
[
elName
]
||
[])
attributeList
.
forEach
(
attr
=>
{
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/alert.spec.js
+
5
-
5
View file @
26d86fce
import
Alert
from
'
../../src/alert
'
import
{
makeArray
,
getTransitionDurationFromElement
}
from
'
../../src/util/index
'
import
{
getTransitionDurationFromElement
}
from
'
../../src/util/index
'
/** Test helpers */
import
{
getFixture
,
clearFixture
,
jQueryMock
}
from
'
../helpers/fixture
'
...
...
@@ -30,7 +30,7 @@ describe('Alert', () => {
const
button
=
document
.
querySelector
(
'
button
'
)
button
.
click
()
expect
(
makeArray
(
document
.
querySelectorAll
(
'
.alert
'
)
)
.
length
).
toEqual
(
0
)
expect
(
document
.
querySelectorAll
(
'
.alert
'
).
length
).
toEqual
(
0
)
})
it
(
'
should close an alert without instantiating it manually with the parent selector
'
,
()
=>
{
...
...
@@ -43,7 +43,7 @@ describe('Alert', () => {
const
button
=
document
.
querySelector
(
'
button
'
)
button
.
click
()
expect
(
makeArray
(
document
.
querySelectorAll
(
'
.alert
'
)
)
.
length
).
toEqual
(
0
)
expect
(
document
.
querySelectorAll
(
'
.alert
'
).
length
).
toEqual
(
0
)
})
})
...
...
@@ -56,7 +56,7 @@ describe('Alert', () => {
const
alert
=
new
Alert
(
alertEl
)
alertEl
.
addEventListener
(
'
closed.bs.alert
'
,
()
=>
{
expect
(
makeArray
(
document
.
querySelectorAll
(
'
.alert
'
)
)
.
length
).
toEqual
(
0
)
expect
(
document
.
querySelectorAll
(
'
.alert
'
).
length
).
toEqual
(
0
)
expect
(
spy
).
not
.
toHaveBeenCalled
()
done
()
})
...
...
@@ -75,7 +75,7 @@ describe('Alert', () => {
})
alertEl
.
addEventListener
(
'
closed.bs.alert
'
,
()
=>
{
expect
(
makeArray
(
document
.
querySelectorAll
(
'
.alert
'
)
)
.
length
).
toEqual
(
0
)
expect
(
document
.
querySelectorAll
(
'
.alert
'
).
length
).
toEqual
(
0
)
done
()
})
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/collapse.spec.js
+
1
-
2
View file @
26d86fce
import
Collapse
from
'
../../src/collapse
'
import
EventHandler
from
'
../../src/dom/event-handler
'
import
{
makeArray
}
from
'
../../src/util/index
'
/** Test helpers */
import
{
getFixture
,
clearFixture
,
jQueryMock
}
from
'
../helpers/fixture
'
...
...
@@ -139,7 +138,7 @@ describe('Collapse', () => {
const
collapseEl1
=
fixtureEl
.
querySelector
(
'
#collapse1
'
)
const
collapseEl2
=
fixtureEl
.
querySelector
(
'
#collapse2
'
)
const
collapseList
=
makeArray
(
fixtureEl
.
querySelectorAll
(
'
.collapse
'
))
const
collapseList
=
[].
concat
(...
fixtureEl
.
querySelectorAll
(
'
.collapse
'
))
.
map
(
el
=>
new
Collapse
(
el
,
{
parent
,
toggle
:
false
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/dom/selector-engine.spec.js
+
5
-
6
View file @
26d86fce
import
SelectorEngine
from
'
../../../src/dom/selector-engine
'
import
{
makeArray
}
from
'
../../../src/util/index
'
/** Test helpers */
import
{
getFixture
,
clearFixture
}
from
'
../../helpers/fixture
'
...
...
@@ -29,7 +28,7 @@ describe('SelectorEngine', () => {
const
div
=
fixtureEl
.
querySelector
(
'
div
'
)
expect
(
makeArray
(
SelectorEngine
.
find
(
'
div
'
,
fixtureEl
))
)
.
toEqual
([
div
])
expect
(
SelectorEngine
.
find
(
'
div
'
,
fixtureEl
)).
toEqual
([
div
])
})
it
(
'
should find elements globaly
'
,
()
=>
{
...
...
@@ -37,7 +36,7 @@ describe('SelectorEngine', () => {
const
div
=
fixtureEl
.
querySelector
(
'
#test
'
)
expect
(
makeArray
(
SelectorEngine
.
find
(
'
#test
'
))
)
.
toEqual
([
div
])
expect
(
SelectorEngine
.
find
(
'
#test
'
)).
toEqual
([
div
])
})
it
(
'
should handle :scope selectors
'
,
()
=>
{
...
...
@@ -52,7 +51,7 @@ describe('SelectorEngine', () => {
const
listEl
=
fixtureEl
.
querySelector
(
'
ul
'
)
const
aActive
=
fixtureEl
.
querySelector
(
'
.active
'
)
expect
(
makeArray
(
SelectorEngine
.
find
(
'
:scope > li > .active
'
,
listEl
))
)
.
toEqual
([
aActive
])
expect
(
SelectorEngine
.
find
(
'
:scope > li > .active
'
,
listEl
)).
toEqual
([
aActive
])
})
})
...
...
@@ -75,8 +74,8 @@ describe('SelectorEngine', () => {
</ul>`
const
list
=
fixtureEl
.
querySelector
(
'
ul
'
)
const
liList
=
makeArray
(
fixtureEl
.
querySelectorAll
(
'
li
'
))
const
result
=
makeArray
(
SelectorEngine
.
children
(
list
,
'
li
'
)
)
const
liList
=
[].
concat
(...
fixtureEl
.
querySelectorAll
(
'
li
'
))
const
result
=
SelectorEngine
.
children
(
list
,
'
li
'
)
expect
(
result
).
toEqual
(
liList
)
})
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/modal.spec.js
+
4
-
5
View file @
26d86fce
import
Modal
from
'
../../src/modal
'
import
EventHandler
from
'
../../src/dom/event-handler
'
import
{
makeArray
}
from
'
../../src/util/index
'
/** Test helpers */
import
{
getFixture
,
clearFixture
,
createEvent
,
jQueryMock
}
from
'
../helpers/fixture
'
...
...
@@ -31,11 +30,11 @@ describe('Modal', () => {
document
.
body
.
classList
.
remove
(
'
modal-open
'
)
document
.
body
.
removeAttribute
(
'
style
'
)
document
.
body
.
removeAttribute
(
'
data-padding-right
'
)
const
backdropList
=
makeArray
(
document
.
querySelectorAll
(
'
.modal-backdrop
'
))
backdropList
.
forEach
(
backdrop
=>
{
document
.
body
.
removeChild
(
backdrop
)
})
document
.
querySelectorAll
(
'
.modal-backdrop
'
)
.
forEach
(
backdrop
=>
{
document
.
body
.
removeChild
(
backdrop
)
})
document
.
body
.
style
.
paddingRight
=
'
0px
'
})
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/popover.spec.js
+
1
-
2
View file @
26d86fce
import
Popover
from
'
../../src/popover
'
import
{
makeArray
}
from
'
../../src/util/index
'
/** Test helpers */
import
{
getFixture
,
clearFixture
,
jQueryMock
}
from
'
../helpers/fixture
'
...
...
@@ -14,7 +13,7 @@ describe('Popover', () => {
afterEach
(()
=>
{
clearFixture
()
const
popoverList
=
makeArray
(
document
.
querySelectorAll
(
'
.popover
'
)
)
const
popoverList
=
document
.
querySelectorAll
(
'
.popover
'
)
popoverList
.
forEach
(
popoverEl
=>
{
document
.
body
.
removeChild
(
popoverEl
)
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/tooltip.spec.js
+
2
-
4
View file @
26d86fce
import
Tooltip
from
'
../../src/tooltip
'
import
EventHandler
from
'
../../src/dom/event-handler
'
import
{
makeArray
,
noop
}
from
'
../../src/util/index
'
import
{
noop
}
from
'
../../src/util/index
'
/** Test helpers */
import
{
getFixture
,
clearFixture
,
jQueryMock
,
createEvent
}
from
'
../helpers/fixture
'
...
...
@@ -15,9 +15,7 @@ describe('Tooltip', () => {
afterEach
(()
=>
{
clearFixture
()
const
tooltipList
=
makeArray
(
document
.
querySelectorAll
(
'
.tooltip
'
))
tooltipList
.
forEach
(
tooltipEl
=>
{
document
.
querySelectorAll
(
'
.tooltip
'
).
forEach
(
tooltipEl
=>
{
document
.
body
.
removeChild
(
tooltipEl
)
})
})
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/util/index.spec.js
+
0
-
14
View file @
26d86fce
...
...
@@ -244,20 +244,6 @@ describe('Util', () => {
})
})
describe
(
'
makeArray
'
,
()
=>
{
it
(
'
should convert node list to array
'
,
()
=>
{
const
nodeList
=
document
.
querySelectorAll
(
'
div
'
)
expect
(
Array
.
isArray
(
nodeList
)).
toEqual
(
false
)
expect
(
Array
.
isArray
(
Util
.
makeArray
(
nodeList
))).
toEqual
(
true
)
})
it
(
'
should return an empty array if the nodeList is undefined
'
,
()
=>
{
expect
(
Util
.
makeArray
(
null
)).
toEqual
([])
expect
(
Util
.
makeArray
(
undefined
)).
toEqual
([])
})
})
describe
(
'
isVisible
'
,
()
=>
{
it
(
'
should return false if the element is not defined
'
,
()
=>
{
expect
(
Util
.
isVisible
(
null
)).
toEqual
(
false
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets