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:
Jo-Philipp Wich 2018-10-20 09:55:59 +02:00
parent 911d540cbb
commit 6b8fc99fd5

View file

@ -1606,6 +1606,9 @@ function matchesElem(node, selector)
function findParent(node, selector)
{
if (node.closest)
return node.closest(selector);
while (node)
if (matchesElem(node, selector))
return node;