Skip to content
GitLab
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
096413a9
Commit
096413a9
authored
6 years ago
by
Johann-S
Committed by
XhmikosR
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
fix(selector-engine): increase coverage for selector engine
parent
4510e7e6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
js/src/dom/selectorEngine.js
+5
-1
js/src/dom/selectorEngine.js
js/tests/index.html
+1
-0
js/tests/index.html
js/tests/unit/.eslintrc.json
+2
-1
js/tests/unit/.eslintrc.json
js/tests/unit/dom/eventHandler.js
+1
-1
js/tests/unit/dom/eventHandler.js
js/tests/unit/dom/selectorEngine.js
+77
-0
js/tests/unit/dom/selectorEngine.js
with
86 additions
and
3 deletions
+86
-3
js/src/dom/selectorEngine.js
+
5
-
1
View file @
096413a9
...
...
@@ -3,7 +3,7 @@ import Util from '../util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.
0.0-beta
): dom/selectorEngine.js
* Bootstrap (v4.
1.1
): dom/selectorEngine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
...
...
@@ -69,6 +69,10 @@ const SelectorEngine = (() => {
},
closest
(
element
,
selector
)
{
if
(
typeof
selector
!==
'
string
'
)
{
return
null
}
return
closest
(
element
,
selector
)
},
...
...
This diff is collapsed.
Click to expand it.
js/tests/index.html
+
1
-
0
View file @
096413a9
...
...
@@ -119,6 +119,7 @@
<script
src=
"unit/dom/eventHandler.js"
></script>
<script
src=
"unit/dom/manipulator.js"
></script>
<script
src=
"unit/dom/data.js"
></script>
<script
src=
"unit/dom/selectorEngine.js"
></script>
<script
src=
"unit/alert.js"
></script>
<script
src=
"unit/button.js"
></script>
<script
src=
"unit/carousel.js"
></script>
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/.eslintrc.json
+
2
-
1
View file @
096413a9
...
...
@@ -15,7 +15,8 @@
"Simulator"
:
false
,
"Toast"
:
false
,
"EventHandler"
:
false
,
"Manipulator"
:
false
"Manipulator"
:
false
,
"SelectorEngine"
:
false
},
"parserOptions"
:
{
"ecmaVersion"
:
5
,
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/dom/eventHandler.js
+
1
-
1
View file @
096413a9
$
(
function
()
{
'
use strict
'
QUnit
.
module
(
'
event
h
andler
'
)
QUnit
.
module
(
'
event
H
andler
'
)
QUnit
.
test
(
'
should be defined
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/dom/selectorEngine.js
0 → 100644
+
77
-
0
View file @
096413a9
$
(
function
()
{
'
use strict
'
QUnit
.
module
(
'
selectorEngine
'
)
QUnit
.
test
(
'
should be defined
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
assert
.
ok
(
SelectorEngine
,
'
Manipulator is defined
'
)
})
QUnit
.
test
(
'
should determine if an element match the selector
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
$
(
'
<input type="checkbox" /> <button class="btn"></button>
'
).
appendTo
(
'
#qunit-fixture
'
)
assert
.
ok
(
!
SelectorEngine
.
matches
(
$
(
'
#qunit-fixture
'
)[
0
],
'
.btn
'
))
assert
.
ok
(
SelectorEngine
.
matches
(
$
(
'
.btn
'
)[
0
],
'
.btn
'
))
})
QUnit
.
test
(
'
should find the selector, according to an element or not
'
,
function
(
assert
)
{
assert
.
expect
(
3
)
$
(
'
<input type="checkbox" /> <button class="btn"></button>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
btn
=
$
(
'
.btn
'
).
first
()[
0
]
assert
.
strictEqual
(
SelectorEngine
.
find
(
$
(
'
.btn
'
)),
null
)
assert
.
equal
(
SelectorEngine
.
find
(
'
.btn
'
)[
0
],
btn
)
assert
.
equal
(
SelectorEngine
.
find
(
'
.btn
'
,
$
(
'
#qunit-fixture
'
)[
0
])[
0
],
btn
)
})
QUnit
.
test
(
'
should find the first element which match the selector, according to an element or not
'
,
function
(
assert
)
{
assert
.
expect
(
3
)
$
(
'
<button class="btn">btn1</button> <button class="btn">btn2</button>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
btn
=
$
(
'
.btn
'
).
first
()[
0
]
assert
.
strictEqual
(
SelectorEngine
.
findOne
(
$
(
'
.btn
'
)),
null
)
assert
.
equal
(
SelectorEngine
.
findOne
(
'
.btn
'
),
btn
)
assert
.
equal
(
SelectorEngine
.
findOne
(
'
.btn
'
,
$
(
'
#qunit-fixture
'
)[
0
]),
btn
)
})
QUnit
.
test
(
'
should find children
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
$
(
'
<button class="btn">btn1</button> <button class="btn">btn2</button> <input type="text" />
'
).
appendTo
(
'
#qunit-fixture
'
)
assert
.
strictEqual
(
SelectorEngine
.
children
(
$
(
'
.btn
'
)),
null
)
assert
.
equal
(
SelectorEngine
.
children
(
$
(
'
#qunit-fixture
'
)[
0
],
'
.btn
'
).
length
,
2
)
})
QUnit
.
test
(
'
should find the selector in parents
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
$
(
'
<input type="text" />
'
).
appendTo
(
'
#qunit-fixture
'
)
assert
.
strictEqual
(
SelectorEngine
.
parents
(
$
(
'
.container
'
)[
0
],
{}),
null
)
assert
.
strictEqual
(
SelectorEngine
.
parents
(
$
(
'
input
'
)[
0
],
'
body
'
).
length
,
1
)
})
QUnit
.
test
(
'
should find the closest element according to the selector
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
var
html
=
'
<div class="test">
'
+
'
<button class="btn"></button>
'
+
'
</div>
'
$
(
html
).
appendTo
(
'
#qunit-fixture
'
)
assert
.
strictEqual
(
SelectorEngine
.
closest
(
$
(
'
.btn
'
)[
0
],
{}),
null
)
assert
.
strictEqual
(
SelectorEngine
.
closest
(
$
(
'
.btn
'
)[
0
],
'
.test
'
),
$
(
'
.test
'
)[
0
])
})
QUnit
.
test
(
'
should fin previous element
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
var
html
=
'
<div class="test"></div>
'
+
'
<button class="btn"></button>
'
$
(
html
).
appendTo
(
'
#qunit-fixture
'
)
assert
.
strictEqual
(
SelectorEngine
.
prev
(
$
(
'
.btn
'
)[
0
],
{}),
null
)
assert
.
strictEqual
(
SelectorEngine
.
prev
(
$
(
'
.btn
'
)[
0
],
'
.test
'
)[
0
],
$
(
'
.test
'
)[
0
])
})
})
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