Skip to content

Sync losos/html.js cache-validity fix from upstream (#15 / linkedobjects/losos#16)#4

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
sync/losos-html-issue-15
May 3, 2026
Merged

Sync losos/html.js cache-validity fix from upstream (#15 / linkedobjects/losos#16)#4
melvincarvalho merged 1 commit into
gh-pagesfrom
sync/losos-html-issue-15

Conversation

@melvincarvalho
Copy link
Copy Markdown
Contributor

Summary

Mirrors linkedobjects/losos#16 into the vendored losos/html.js copy.

The upstream fix added a container.firstChild guard before taking the patch fast-path in render(). Without it, after the container's children were cleared externally (e.g. the LOSOS shell does content.innerHTML = '' between tab switches), the cache still hit and patch() updated detached nodes — visible as blank source-pane after tab-switching in this repo.

2 lines changed, +90 bytes.

Test plan

  • node -c losos/html.js syntax passes.
  • Manual: served via JSS at localhost:4443/..., switch Sharing → Source → Sharing → Source — source-pane renders consistently every time. Was: blank after the second visit. Now: works.
  • Static template hot-path preserved: firstChild is truthy when ANY rendered child remains, so templates with zero ${} holes still hit the patch shortcut on rerender.

Out of scope

  • Eliminating the duplicate vendored copy of LOSOS at losos/ in this repo and depending on @linkedobjects/losos from npm — separate concern, mirrors the duplicate-source issue tracked at linkedobjects/losos#17.

linkedobjects/losos#16 added a `container.firstChild` guard to the
patch fast-path in `render()`, so a stale cache after the container
was wiped externally falls through to a fresh build instead of
silently no-op'ing on detached nodes. Mirror the upstream change
into the vendored copy at `losos/html.js`.

Net diff: 2 lines, +90 bytes. Fixes source-pane going blank after
tab-switching in the LOSOS shell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant