luci-base: cbi.js: utilize node.closest() if available
Use node.closest() in findParent() when available since it should be faster than manaually traversing the ancestor chain. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
911d540cbb
commit
6b8fc99fd5
1 changed files with 3 additions and 0 deletions
|
@ -1606,6 +1606,9 @@ function matchesElem(node, selector)
|
||||||
|
|
||||||
function findParent(node, selector)
|
function findParent(node, selector)
|
||||||
{
|
{
|
||||||
|
if (node.closest)
|
||||||
|
return node.closest(selector);
|
||||||
|
|
||||||
while (node)
|
while (node)
|
||||||
if (matchesElem(node, selector))
|
if (matchesElem(node, selector))
|
||||||
return node;
|
return node;
|
||||||
|
|
Loading…
Reference in a new issue