From 58f6219cb3cf937fef59d03d4420de1ba64df436 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 31 Mar 2024 14:33:08 +0100 Subject: [PATCH] Code: Fixed highlighting issues when no code language set For #4917 --- resources/js/code/index.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/js/code/index.mjs b/resources/js/code/index.mjs index d252f8f41..ab31e3f74 100644 --- a/resources/js/code/index.mjs +++ b/resources/js/code/index.mjs @@ -48,14 +48,16 @@ function highlightElem(elem) { const content = elem.textContent.trimEnd(); let langName = ''; + let innerCodeDirection = ''; if (innerCodeElem !== null) { langName = innerCodeElem.className.replace('language-', ''); + innerCodeDirection = innerCodeElem.getAttribute('dir'); } const wrapper = document.createElement('div'); elem.parentNode.insertBefore(wrapper, elem); - const direction = innerCodeElem.getAttribute('dir') || elem.getAttribute('dir') || ''; + const direction = innerCodeDirection || elem.getAttribute('dir') || ''; if (direction) { wrapper.setAttribute('dir', direction); }