diff options
| author | Johann-S <[email protected]> | 2019-03-24 18:30:30 +0100 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2019-07-23 14:23:50 +0200 |
| commit | c834895fa0e7d215ee8cb17b3efa8d0ce57a718c (patch) | |
| tree | fa363c37d5924a7b78d4f250b74f4056b94e3445 /js/src/dom/selector-engine.js | |
| parent | fe6ba2384ae87b8328d2420859b396c28867dbb4 (diff) | |
| download | bootstrap-c834895fa0e7d215ee8cb17b3efa8d0ce57a718c.tar.xz bootstrap-c834895fa0e7d215ee8cb17b3efa8d0ce57a718c.zip | |
rewrite unit tests for selector engine
Diffstat (limited to 'js/src/dom/selector-engine.js')
| -rw-r--r-- | js/src/dom/selector-engine.js | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/js/src/dom/selector-engine.js b/js/src/dom/selector-engine.js index eb6b680ac..d66d8acfc 100644 --- a/js/src/dom/selector-engine.js +++ b/js/src/dom/selector-engine.js @@ -22,37 +22,22 @@ const SelectorEngine = { }, find(selector, element = document.documentElement) { - if (typeof selector !== 'string') { - return null - } - return findFn.call(element, selector) }, findOne(selector, element = document.documentElement) { - if (typeof selector !== 'string') { - return null - } - return findOne.call(element, selector) }, children(element, selector) { - if (typeof selector !== 'string') { - return null - } - const children = makeArray(element.children) return children.filter(child => this.matches(child, selector)) }, parents(element, selector) { - if (typeof selector !== 'string') { - return null - } - const parents = [] + let ancestor = element.parentNode while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { @@ -67,19 +52,12 @@ const SelectorEngine = { }, closest(element, selector) { - if (typeof selector !== 'string') { - return null - } - return closest.call(element, selector) }, prev(element, selector) { - if (typeof selector !== 'string') { - return null - } - const siblings = [] + let previous = element.previousSibling while (previous && previous.nodeType === Node.ELEMENT_NODE && previous.nodeType !== NODE_TEXT) { |
