From 218bac6ecef1c14c2e05c9fffd4b3651dd8be0a5 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 2 Feb 2024 10:44:51 +0100 Subject: [PATCH] Simplify besGetBlockParent() --- online-editor.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/online-editor.js b/online-editor.js index 908aa72..d5813fe 100644 --- a/online-editor.js +++ b/online-editor.js @@ -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 }