[STC-823] Documents not working on exotic browsers

https://community.openproject.org/wp/STC-823

On epiphany, I got the following error:
SyntaxError: The string did not match the expected pattern.
add --- block-note-element.ts:54
BlockNoteElement --- block-note-element.ts:54
define
Module Code --- block-note-element.ts:151

The root cause is that browser_specific_classes in BrowserHelper only adds classes for Chrome, Firefox, Safari, Edge, and mobile/Windows. Epiphany (WebKitGTK on Linux) doesn't match any of those, so it returns []. The ERB template then renders browser-specific-classes="", and "".split(' ') in JS produces [""] — one empty string — which passes the length > 0 guard and then classList.add("") throws in WebKit.
This commit is contained in:
Judith Roth
2026-06-08 19:03:47 +02:00
parent dc1d965423
commit 1860efa7af
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ class BlockNoteElement extends HTMLElement {
const shadowRoot = this.attachShadow({ mode: 'open' });
this.editorRoot = document.createElement('div');
const browserSpecificClasses = this.getAttribute('browser-specific-classes')?.split(' ') ?? [];
const browserSpecificClasses = this.getAttribute('browser-specific-classes')?.split(' ').filter(Boolean) ?? [];
if (browserSpecificClasses.length > 0) {
this.editorRoot.classList.add(...browserSpecificClasses);
}
@@ -41,7 +41,7 @@
"attachments-collection-key": attachments_collection_key,
"blocknote-stylesheet-url": blocknote_stylesheet_url,
"shadow-dom-stylesheet-url": shadow_dom_stylesheet_url,
"browser-specific-classes": browser_specific_classes.join(" "),
"browser-specific-classes": browser_specific_classes.join(" ").presence,
"data-test-selector": "blocknote-document-description"
)
)