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
7c1d0a10
Commit
7c1d0a10
authored
7 years ago
by
Johann-S
Committed by
XhmikosR
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Wrap our objects into IIFE
parent
bcbea028
5 merge requests
!31948
Examples/Floating-labels: fix bad behavior with autofill
,
!30064
test
,
!29779
Responsive sizing
,
!28882
fix custom-select-indicator in IE10
,
!28721
Hot test
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
js/src/dom/data.js
+52
-42
js/src/dom/data.js
js/src/dom/eventHandler.js
+277
-255
js/src/dom/eventHandler.js
js/src/dom/selectorEngine.js
+66
-56
js/src/dom/selectorEngine.js
with
395 additions
and
353 deletions
+395
-353
js/src/dom/data.js
+
52
-
42
View file @
7c1d0a10
...
@@ -5,56 +5,66 @@
...
@@ -5,56 +5,66 @@
* --------------------------------------------------------------------------
* --------------------------------------------------------------------------
*/
*/
const
mapData
=
(()
=>
{
const
Data
=
(()
=>
{
const
storeData
=
{}
let
id
=
1
/**
return
{
* ------------------------------------------------------------------------
set
(
element
,
key
,
data
)
{
* Constants
if
(
typeof
element
.
key
===
'
undefined
'
)
{
* ------------------------------------------------------------------------
element
.
key
=
{
*/
key
,
id
const
mapData
=
(()
=>
{
const
storeData
=
{}
let
id
=
1
return
{
set
(
element
,
key
,
data
)
{
if
(
typeof
element
.
key
===
'
undefined
'
)
{
element
.
key
=
{
key
,
id
}
}
}
}
storeData
[
id
]
=
data
storeData
[
id
]
=
data
id
++
id
++
},
},
get
(
element
,
key
)
{
get
(
element
,
key
)
{
if
(
typeof
element
===
'
undefined
'
||
typeof
element
.
key
===
'
undefined
'
)
{
if
(
typeof
element
===
'
undefined
'
||
typeof
element
.
key
===
'
undefined
'
)
{
return
null
}
const
keyProperties
=
element
.
key
if
(
keyProperties
.
key
===
key
)
{
return
storeData
[
keyProperties
.
id
]
}
return
null
return
null
}
},
delete
(
element
,
key
)
{
if
(
typeof
element
.
key
===
'
undefined
'
)
{
return
}
const
keyProperties
=
element
.
key
const
keyProperties
=
element
.
key
if
(
keyProperties
.
key
===
key
)
{
if
(
keyProperties
.
key
===
key
)
{
return
storeData
[
keyProperties
.
id
]
delete
storeData
[
keyProperties
.
id
]
}
delete
element
.
key
return
null
}
},
delete
(
element
,
key
)
{
if
(
typeof
element
.
key
===
'
undefined
'
)
{
return
}
}
}
})()
const
keyProperties
=
element
.
key
return
{
if
(
keyProperties
.
key
===
key
)
{
setData
(
instance
,
key
,
data
)
{
delete
storeData
[
keyProperties
.
id
]
mapData
.
set
(
instance
,
key
,
data
)
delete
element
.
key
},
}
getData
(
instance
,
key
)
{
return
mapData
.
get
(
instance
,
key
)
},
removeData
(
instance
,
key
)
{
mapData
.
delete
(
instance
,
key
)
}
}
}
}
})()
})()
const
Data
=
{
setData
(
instance
,
key
,
data
)
{
mapData
.
set
(
instance
,
key
,
data
)
},
getData
(
instance
,
key
)
{
return
mapData
.
get
(
instance
,
key
)
},
removeData
(
instance
,
key
)
{
mapData
.
delete
(
instance
,
key
)
}
}
export
default
Data
export
default
Data
This diff is collapsed.
Click to expand it.
js/src/dom/eventHandler.js
+
277
-
255
View file @
7c1d0a10
This diff is collapsed.
Click to expand it.
js/src/dom/selectorEngine.js
+
66
-
56
View file @
7c1d0a10
...
@@ -5,76 +5,86 @@
...
@@ -5,76 +5,86 @@
* --------------------------------------------------------------------------
* --------------------------------------------------------------------------
*/
*/
// matches polyfill (see: https://mzl.la/2ikXneG)
const
SelectorEngine
=
(()
=>
{
let
fnMatches
=
null
if
(
!
Element
.
prototype
.
matches
)
{
fnMatches
=
Element
.
prototype
.
msMatchesSelector
||
Element
.
prototype
.
webkitMatchesSelector
}
else
{
fnMatches
=
Element
.
prototype
.
matches
}
// closest polyfill (see: https://mzl.la/2vXggaI)
let
fnClosest
=
null
if
(
!
Element
.
prototype
.
closest
)
{
fnClosest
=
(
element
,
selector
)
=>
{
let
ancestor
=
element
if
(
!
document
.
documentElement
.
contains
(
element
))
{
return
null
}
do
{
if
(
fnMatches
.
call
(
ancestor
,
selector
))
{
return
ancestor
}
ancestor
=
ancestor
.
parentElement
/**
}
while
(
ancestor
!==
null
)
* ------------------------------------------------------------------------
* Polyfills
* ------------------------------------------------------------------------
*/
return
null
// matches polyfill (see: https://mzl.la/2ikXneG)
let
fnMatches
=
null
if
(
!
Element
.
prototype
.
matches
)
{
fnMatches
=
Element
.
prototype
.
msMatchesSelector
||
Element
.
prototype
.
webkitMatchesSelector
}
else
{
fnMatches
=
Element
.
prototype
.
matches
}
}
}
else
{
// eslint-disable-next-line arrow-body-style
fnClosest
=
(
element
,
selector
)
=>
{
return
element
.
closest
(
selector
)
}
}
const
SelectorEngine
=
{
// closest polyfill (see: https://mzl.la/2vXggaI)
matches
(
element
,
selector
)
{
let
fnClosest
=
null
return
fnMatches
.
call
(
element
,
selector
)
if
(
!
Element
.
prototype
.
closest
)
{
},
fnClosest
=
(
element
,
selector
)
=>
{
let
ancestor
=
element
if
(
!
document
.
documentElement
.
contains
(
element
))
{
return
null
}
do
{
if
(
fnMatches
.
call
(
ancestor
,
selector
))
{
return
ancestor
}
ancestor
=
ancestor
.
parentElement
}
while
(
ancestor
!==
null
)
find
(
selector
,
element
=
document
)
{
if
(
typeof
selector
!==
'
string
'
)
{
return
null
return
null
}
}
}
else
{
if
(
selector
.
indexOf
(
'
#
'
)
===
0
)
{
// eslint-disable-next-line arrow-body-style
return
SelectorEngine
.
findOne
(
selector
,
element
)
fnClosest
=
(
element
,
selector
)
=>
{
return
element
.
closest
(
selector
)
}
}
}
return
element
.
querySelectorAll
(
selector
)
return
{
},
matches
(
element
,
selector
)
{
return
fnMatches
.
call
(
element
,
selector
)
},
find
One
(
selector
,
element
=
document
)
{
find
(
selector
,
element
=
document
)
{
if
(
typeof
selector
!==
'
string
'
)
{
if
(
typeof
selector
!==
'
string
'
)
{
return
null
return
null
}
}
let
selectorType
=
'
querySelector
'
if
(
selector
.
indexOf
(
'
#
'
)
===
0
)
{
if
(
selector
.
indexOf
(
'
#
'
)
===
0
)
{
return
SelectorEngine
.
findOne
(
selector
,
element
)
selectorType
=
'
getElementById
'
}
selector
=
selector
.
substr
(
1
,
selector
.
length
)
}
return
element
.
querySelectorAll
(
selector
)
},
return
element
[
selectorType
](
selector
)
findOne
(
selector
,
element
=
document
)
{
},
if
(
typeof
selector
!==
'
string
'
)
{
return
null
}
let
selectorType
=
'
querySelector
'
if
(
selector
.
indexOf
(
'
#
'
)
===
0
)
{
selectorType
=
'
getElementById
'
selector
=
selector
.
substr
(
1
,
selector
.
length
)
}
closest
(
element
,
selector
)
{
return
element
[
selectorType
](
selector
)
return
fnClosest
(
element
,
selector
)
},
closest
(
element
,
selector
)
{
return
fnClosest
(
element
,
selector
)
}
}
}
}
}
)()
export
default
SelectorEngine
export
default
SelectorEngine
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