So ... I think I have to recommend against using #Lit to build whole websites, because it doesn't seem to support fragment links (https://example/#this-is-the-fragment) well or at all. It's great at building discrete elements without user-addressable parts, but that's not enough for rendering the top level of a whole page.

Tell me I'm wrong at github.com/lit/lit/discussions.

#WebComponents #CustomElements

@jyasskin well that seems like a crazy shortcoming. Shocked that doesn't seem to have come up before and been addressed. I guess there's not a convenient way to have the fragment break out of the shadowDom or be exposed somehow?

@mcneely It could be that people writing client-side renderers have already given up on fragments. But I was also surprised not to find any bugs about it.

@jyasskin complete guess but my only thought is that most of the folks using fragments like that are doing anchors in Markdown so it hasn't come up for web components?

@jyasskin @mcneely We can talk further in the Lit discussion you started, but this really has nothing to do with Lit per se, it’s just a limitation of Shadow DOM that has been known for years and not (yet?) risen to a high enough priority to get addressed.

@jyasskin @mcneely That’s probably because most people using web components for content-heavy sites don’t put content in Shadow DOM; they either use web components for “islands of interactivity” or use slots to project light-DOM content into custom elements providing structure / style / behavior.

@jyasskin @mcneely If for some reason you did have a site where a significant amount of content was beneath shadow roots, it should be relatively straightforward to write some custom client-side routing logic to make fragments work.

@graynorton @jyasskin make sense. I was thinking more about this after my last post. Makes sense that it doesn't work and even more sense that it has come up before, even if there's no definitive resolution.

@graynorton @mcneely It's a #Lit issue because Lit is alone among the major frameworks in putting component content in #ShadowDOM. It's true that a fix probably needs shadow dom changes, but people using Lit need to know the uses that they're going to have to code manually, and it's Lit folks who have the most expertise to use when pushing for these #WebStandards changes.

Sign in to participate in the conversation
Librem Social

Librem Social is an opt-in public network. Messages are shared under Creative Commons BY-SA 4.0 license terms. Policy.

Stay safe. Please abide by our code of conduct.

(Source code)

image/svg+xml Librem Chat image/svg+xml