JSX ref forwarding + general-purpose Dart Node VS Code extension#66
Open
MelbourneDeveloper wants to merge 1 commit into
Open
JSX ref forwarding + general-purpose Dart Node VS Code extension#66MelbourneDeveloper wants to merge 1 commit into
MelbourneDeveloper wants to merge 1 commit into
Conversation
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.
TLDR
Finish the JSX DSL by adding
refforwarding (with acloneElementfix soref/keysurvive>>recomposition) and rebrand the VS Code extension into a general-purpose "Dart Node" extension with four basic commands.What Was Added?
packages/dart_node_react): optionalref:(aJsReffromcreateRef) on$div,$input,$button,$textarea,$a,$select,$form,$img,$video,$audio.cloneElementWithRawChildrenhelper inreact.dart(delegates to the existing clone machinery; no duplication).vscode.versionbinding indart_node_vsix.dartNode.hello(greeting),dartNode.showVersion(vscode.version),dartNode.echo(input box → message),dartNode.count(persisted run counter viaglobalStatememento).refleaf + recomposition tests; aglobalStatememento round-trip self-check + assertion.What Was Changed or Deleted?
Elrecomposition now usescloneElementinstead ofcreateElement. React 18 hoistsref/keyout ofprops, so rebuilding frompropsdropped them whenever>>attached children;cloneElementpreservesref/key/props. This also fixes a latentkey-drop on recomposition.Mementobinding (extension_context.dart):get/update/keysnow dispatch on the memento object viacallMethodinstead of unnamed@JS()externals that resolved to nonexistent globals (globalThis._mementoGet). The previous binding threw at runtime for any caller.dart-node-vsix-test/ "Dart Node VSIX Test" →dart-node/ "Dart Node"; idsdartNodeVsix.*→dartNode.*; output channel / status bar / log labels → "Dart Node";extensionIdandpackage-lock.jsonname updated to match.test/jsx/jsx_dsl_test.dart— a strict subset ofjsx_test.dart(removes duplication).How Do The Automated Tests Prove It Works?
packages/dart_node_react/test/jsx_test.dart(18 tests, Chrome):ref forwards to the rendered DOM nodeandref survives recomposition when children are added with >>assertref.jsRef.currentis non-null after render — the second exercises the$button(ref:) >> 'Save'path that fails without thecloneElementfix. All existing DSL tests (text/nested/events/fragment/conditional/numeric/keys/spread/override) still pass.packages/dart_node_vsix/test/suite/extension_activation_test.dart:globalState memento round-trips through the bindingasserts the activation self-check wrote7and read it back. Because that round-trip runs insideactivate, a broken memento binding fails activation and the entire suite — so the suite guards it.packages/dart_node_vsix/test/suite/commands_test.dart: asserts all fivedartNode.*commands are registered.make cigreen across all three tiers):dart analyzeanddart formatclean;cspellclean;extension.dartcompilesdart compile js -O2with the memento dispatchingglobalState.get(...)/globalState.update(...)on the object (no global lookups).Spec / Doc Changes
docs/plans/JSX_IMPLEMENTATION_PLAN.md: replaced "Open Questions"/"Next Steps" with Resolved Decisions, Phase Status, and a TODO checklist (Phase 1 shipped; later phases deferred).packages/dart_node_vsix/README.md: added a "Bundled extension: Dart Node" section documenting the commands.Breaking Changes
refparams, newvscode.versiongetter) or bug fixes (theMementobinding now works). The id/manifest rename (dartNodeVsix.*→dartNode.*,Nimblesite.dart-node-vsix-test→Nimblesite.dart-node) affects only the bundled demo extension (publish_to: none), not a published surface.