Repository navigation
feat: run the UI directives on the NoJS-Server host backend - #126
Merged
Merged
Conversation
Every UI module registers one implementation through defineDirective, which hands init (el, expr, be) on both backends. Core keeps its exact behavior; on a compiled site the body reads server-delivered values with host.value, disposes through host.onDispose and marks directives that restructure their subtree (tabs, accordion, stepper, split, ...) with subtree: true. The contract declares the expression attributes (tooltip-disabled, tab-disabled, skeleton, step-validate, toast).
A server re-render re-initializes subtree-owning tabs and steppers on a compiled site; the ids they generated go back to the same positions, as core initializes them once. Declaring sort keeps the attribute on table headers, where the compiler otherwise strips it as a loop companion.
Core's watcher applies it on the first state change after init; the host watcher fires only when the delivered value changes, so a locked row stayed draggable on compiled sites.
sort is also core's loop companion; loop rows rendered after Elements installed got data-sortable, aria-sort and tabindex=0. Visible change: those rows leave the tab order and lose the sort attributes.
ErickXavier
marked this pull request as ready for review
November 20, 2026 20:05
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.
Summary
On a NoJS-Server compiled site (
NoJS.hostApi >= 1) Elements 1.23 installed only dnd and validate. This runs every UI element on the host backend: accordion, breadcrumb, dropdown, modal, popover, scroll-spy, skeleton, split, stepper, table (sortable / sort / fixed-header / fixed-col / table-reorder), tabs, toast, tooltip, tree (with drag) and virtual-list. Found by the reference-site acceptance run (DIVERGENCES D-ELEMENTS-UI).src/_backend.jsdefineDirective(NoJS, name, { priority, subtree, init(el, expr, be) }). Core pages run exactly the code they ran before (sameexpr, disposers onel.__disposers); the existing core-mode unit and e2e suites are unchanged and pass.host.value(tooltip-disabled,tab-disabled,skeleton,step-validate,toastoutside buttons/links/on:click); cleanup throughhost.onDispose; directives that build their own subtree declaresubtree: true(tabs, accordion, stepper, split, skeleton, breadcrumb, toast-container, sortable, table-reorder, tree, tree-drag-mode, virtual, spy).src/ui-contract.js: the contract declares the expression attributes,sort(literal; keeps the attribute on table headers) andtoastwithliteralOn.location.pathnameand the integrator'snojs:navigateevent.NoJS.modal/dropdown/popover/toastare also set on the page-levelwindow.NoJS.drag-disabledis applied at init on the host backend (D-DRAG-DISABLED-INIT).Needs the NoJS-Server host API extensions (
subtree, client-owned attributes, core-order init,literalOn,nojs:navigate) from no-js-dev/nojs-serverfeat/host-ui-api. With an older integrator the directives still run;subtreeis ignored.Known differences on compiled sites (documented in CHANGELOG)
$stepperand$toastare not available to expressions (expressions run on the server).drag-list/drag-multipleremain host stubs.Tests
__tests__/ui-host.test.js(27): host install, subtree flags, contract, page APIs, and each directive on a stand-in host (values, watch, dispose, re-init state and ids).e2e/tests/ui-host.spec.ts(16 x 3 browsers) one2e/examples/ui-host.htmlwith a stand-in plugin host.npm test: 834 passed, 5 skipped. E2E: 702 passed (chromium, firefox, webkit).elements-disclosure,elements-overlays,elements-navigation,elements-data,dnd-reorder,validate-formpass; reference sitej1b-docspasses compiled.Fixes in core mode too (lead decisions)
sortmarks only a<th>inside a table.sortis also core's loop companion; loop rows rendered after Elements installed gotdata-sortable,aria-sort="none",tabindex="0". Visible change: those rows leave the tab order and lose the sort attributes. Tests in both modes. (Reference site D-DND-SORT-CHILDREN.)virtualattribute; a "Server-Rendered Hosts" section on every element page and inllms-full.txt;llms.txtupdated.For the release sync (not in this PR)
directives.json,nojs-custom-data.json, hover docs): addvirtualas the required virtual-list attribute; note thatsortis valid on<th>only for the table directive; optionally a "server-rendered hosts" line in hovers for table, virtual-list, stepper ($stepper), toast ($toast).references/elements/*.md,SKILL.md): virtual-list examples needvirtual; server-rendered host notes (table sort/reorder move rendered rows, virtual-list windows server-rendered rows,$stepper/$toastunavailable in expressions, toast literal vs expression);references/core/plugins.md: host directive optionsubtree, contractliteralOn,nojs:navigate.