Simplify besGetBlockParent()

This commit is contained in:
Simon Rozman 2024-02-02 10:44:51 +01:00
parent b034d5dd56
commit 218bac6ece

View File

@ -186,18 +186,8 @@ function besIsBlockElement(el)
// Returns first block parent element
function besGetBlockParent(el, edit)
{
while (el && el !== edit) {
switch (el.nodeType) {
case Node.TEXT_NODE:
el = el.parentNode
break
case Node.ELEMENT_NODE:
if (besIsBlockElement(el)) {
return el
}
el = el.parentNode
}
for (; el && el !== edit; el = el.parentNode) {
if (el.nodeType === Node.ELEMENT_NODE && besIsBlockElement(el)) return el
}
return el
}