vatro / svelthree

Create three.js content using Svelte components.

Home Page:https://svelthree.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change `SvelthreeLogger.get_comp_name` to strip more suffixes

vatro opened this issue · comments

After reinstalling modules in the test-scenes project, I started getting e.g. Scene2 as comp.constructor.name, so the shadow DOM creation logic which relies on the returned logic:

if (c_name !== "Scene") {
if (our_parent_shadow_dom_el) {
our_parent_shadow_dom_el.appendChild(shadow_dom_el)
return shadow_dom_el
} else {
console.error(
`SVELTHREE > ${c_name} > create_shadow_dom_el > couldn't append shadow dom, no 'our_parent_shadow_dom_el'!`,
our_parent_shadow_dom_el
)
return null
}
} else {
return shadow_dom_el
}

wasn't returning the correct shadow_dom_el / failed.

So, a quick fix would be to change the replace search-string to a RegEx catching any underscores and numbers.
Fun fact: I asked ChatGPT what this kind of RegEx would look like, it gave me: [\d_]/g.

Atm, the SvelteKit / Vite classes suffixing (if duplicate names) / chunks naming behavior a bit of a black box to me and should be examined / nailed down, see #193