fix: #282 harden src/jsx-loader.js — 8 JSX + inferred-observability defects#283
Open
jstockdi wants to merge 8 commits into
Open
Conversation
…nt-rooted JSX render output
…ss in jsx-loader
…rite `this` via the ast
…ttributeChangedCallback
…Identifier` so observability effects don't call `undefined.$$tmpl0`
…s inferred observability
…ctly in jsx instead of undefined.get()
… of silently dropping them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Resolves #282
Summary of Changes
Eight correctness/DX defects in
src/jsx-loader.js, one commit (fix + regression test) each. Every regression test fails on the unpatched compiler and passes with its fix; all 8 newjsx-*cases pass together (npm run test:jsxgreen, coverage above.c8rc.jsongates), andnpm testis unaffected..map()lists, computed members) produced no output and no diagnostic; aconsole.warnnow fires from the fall-through naming the expression. Also handles the childLiteralidiom ({' '},{'text'},{42}) that was itself being dropped. Non-fatal — behavior is otherwise unchanged.{this.count.get()}signal reads directly instead of compiling to${undefined.get()}(which crashed SSR). Mirrors the destructured{count.get()}form; the destructured path is unchanged. (The chained{this.todos.get().length}variant is left as a follow-up.)export const inferredObservability = falsenow disables inferred observability — used the parsed literal value instead ofBoolean(init.raw)(which wastruefor the source text"false").export default Identifierform (class X extends HTMLElement {}; customElements.define(...); export default X;), so the effect-append pass no longer emitsundefined.$$tmpl0(...). The inlineexport default class Nameform is unaffected.observedAttributes/attributeChangedCallbackwhen the component defines its own — the deadhasOwnObservedAttributesflag is now actually set during the class walk, honoring the existing skip guards.thisvia the AST. A double-quoted string inside anonclick={() => …}handler no longer breaks the attribute, andthisinside string literals is left intact (ThisExpressionnodes are rewritten viaacorn-walkinstead of a/this./gregex).node.superClassfor a class withoutextends— a plain helperclass Foo {}in a.jsxfile no longer crashes compilation withCannot read properties of null (reading 'name').<body>-rooted "page" component no longer emits a nested full<html><head></head><body>…</body></html>document. Normal fragment rendering is byte-identical (guarded on the full-document parse path).No breaking changes. Each fix is minimal and confined to its concern; defect 1 is diagnostic-only (a warning, not a hard error), so builds that currently produce partial output keep building, now with a hint about what was dropped.