@loadbare/app 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,216 @@
1
+ # Prior art
2
+
3
+ > **LLM-researched, not yet revised by a person.** Compiled by Claude on
4
+ > 2026-09-16 from web sources, against `@loadbare/app` 0.7.3, while designing
5
+ > conditional rendering. The sources are listed under each section.
6
+
7
+ Loadbare binds HTML to data by attributes and lets the platform do the DOM
8
+ work. That idea has been tried before. This document records the two
9
+ closest predecessors, where Loadbare agrees with them and where it parts
10
+ ways, and what other frameworks do about conditional rendering.
11
+
12
+ ## The short version
13
+
14
+ Loadbare is not Model-Driven Views, although MDV is the better-known name.
15
+ MDV's model is a mutable object graph in the browser that the view observes.
16
+ Loadbare has no model in the browser: the view is driven by server responses
17
+ that say what changed.
18
+
19
+ The closer ancestor is Internet Explorer 4's data binding, from 1997, whose
20
+ vocabulary of record sets, single records and columns maps almost one to one
21
+ onto Loadbare's.
22
+
23
+ Loadbare can be described as IE4's relational binding vocabulary, on the
24
+ `<template>` element that MDV left behind, with the server as the model.
25
+ Andromeda (2003), where Loadbare began, sits between the two.
26
+
27
+ ## Internet Explorer 4 data binding (1997)
28
+
29
+ Internet Explorer 4.0 bound HTML to data through attributes, built from four
30
+ parts: a data source object (DSO), data consumers, a binding agent and a
31
+ table repetition agent. A DSO might take "an Open Database Connectivity
32
+ (ODBC) connection string and an Structured Query Language (SQL) statement,"
33
+ and had to expose its data through OLE DB.
34
+
35
+ | IE4 | Loadbare |
36
+ |-----------------------------------------------------------------------------|-----------------------|
37
+ | `DATASRC` on a table repeats "an entire set of records" ("set binding") | `lb-list` |
38
+ | A single-valued consumer takes one value "from the current record" | `lb-row` |
39
+ | `DATAFLD` names "a column in the data set" | `lb-cell` |
40
+ | The repetition agent "uses the table row (tr) in the table body as a template" | `<template lb-key>` |
41
+ | The DSO's SQL statement | a page's queries |
42
+ | The binding agent "work[s] completely behind the scenes" | the hub |
43
+
44
+ It differed from Loadbare in three ways:
45
+
46
+ - **The data lived in the browser.** "Since the DSO maintains the data on the
47
+ client, it also manages how the data is sorted and filtered."
48
+ - **Binding was two-way.** "When a user updates a databound element on the
49
+ page, the binding agent notifies the DSO." Loadbare sends a request and
50
+ lands the answer.
51
+ - **It was proprietary.** A DSO was an ActiveX control or applet, and the
52
+ feature ended with Internet Explorer.
53
+
54
+ Sources:
55
+ [About Data Binding Architecture](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms531384(v=vs.85)),
56
+ [Using the Tabular Data Control](https://www.sitepoint.com/control-internet-explorer/).
57
+
58
+ ## Model-Driven Views (2011–2015)
59
+
60
+ ### What it was
61
+
62
+ Rafael Weinstein proposed MDV to the W3C WebApps group in April 2011:
63
+ "Myself and a few other chromium folks have been working on a design for a
64
+ formalized separation between View and Model in the browser." Its README
65
+ calls it "a way to write _dynamic_ HTML _using_ HTML," with the goal of native
66
+ implementation in browsers.
67
+
68
+ - `{{path.to.value}}` placeholders in text and attribute values, with a
69
+ custom syntax API for expressions.
70
+ - `<template bind>` for one instance, `<template repeat>` for one instance
71
+ per array item, `<template if>` to make either conditional, and
72
+ `<template ref>` to reuse another template's content.
73
+ - Two-way binding on inputs: "If DOM elements which collect user input are
74
+ bound, they _push_ the collected value into the model."
75
+ - A conditional attribute, `hidden?`: "the attribute will be set to the empty
76
+ string if the value is reachable and truthy, otherwise the attribute will be
77
+ removed."
78
+ - Models are plain JavaScript objects, observed through `Object.observe`.
79
+
80
+ In the TemplateBinding implementation, a template stays in the document and
81
+ its instances are inserted after it, tracked by a terminator node. When `if`
82
+ turns false, instances are removed and their bindings closed.
83
+
84
+ ### What became of it
85
+
86
+ The W3C group asked for MDV to be broken into primitives. In Weinstein's
87
+ account those became DOM Mutation Observers, **the HTML `<template>`
88
+ element**, and `Object.observe`. `<template>` was specified by Weinstein and
89
+ reported stable in May 2013. No source found states outright that
90
+ `<template>` was created for MDV, but they share an author, a period and a
91
+ design.
92
+
93
+ The rest did not survive:
94
+
95
+ - `Object.observe` was withdrawn from TC39 in November 2015. It disabled
96
+ optimization paths in V8, and Polymer found that complex applications made
97
+ "tens of thousands of O.o calls."
98
+ - Without native observation, MDV had to keep a list of bindings, and a node
99
+ discarded without being unbound was never garbage collected.
100
+ - The Polymer community debated whether the model or the markup should be the
101
+ source of truth, and settled on the model.
102
+ - The binding half continues in Apple's Template Instantiation proposal (2017)
103
+ and Chrome's DOM Parts, which as of 2025 was pending, with no signals from
104
+ Gecko or WebKit.
105
+
106
+ Sources:
107
+ [Weinstein, "Model-driven Views"](https://lists.w3.org/Archives/Public/public-webapps/2011AprJun/0309.html),
108
+ [MDV README](https://github.com/toolkitchen/mdv),
109
+ [MDV template.md](https://raw.githubusercontent.com/toolkitchen/mdv/master/docs/template.md),
110
+ [MDV node_bind.md](https://raw.githubusercontent.com/toolkitchen/mdv/master/docs/node_bind.md),
111
+ [TemplateBinding source](https://raw.githubusercontent.com/googlearchive/TemplateBinding/master/src/TemplateBinding.js),
112
+ [Will MDV become a standard?](https://groups.google.com/g/polymer-dev/c/4RSYaKmbtEk/m/uYnY3900wpIJ),
113
+ [MDV or markup as data](https://groups.google.com/g/polymer-dev/c/FJQLrcSKGT0),
114
+ [Polymer issue #154](https://github.com/Polymer/polymer/issues/154),
115
+ [W3C HTML Templates, 2013](https://www.w3.org/TR/2013/WD-html-templates-20130214/),
116
+ [InfoQ: Object.observe withdrawn](https://www.infoq.com/news/2015/11/object-observe-withdrawn/),
117
+ [esdiscuss: An update on Object.observe](https://esdiscuss.org/topic/an-update-on-object-observe),
118
+ [Template Instantiation](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Template-Instantiation.md),
119
+ [DOM Parts](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/DOM-Parts.md),
120
+ [Intent to Prototype: DOM Parts](https://groups.google.com/a/chromium.org/g/blink-dev/c/wIADRnljZDA).
121
+
122
+ ## Where the three overlap
123
+
124
+ **All three:**
125
+
126
+ - Dynamic HTML declared in HTML.
127
+ - Attributes naming data on ordinary elements.
128
+ - The platform, not the application, performs the DOM work, with no virtual
129
+ DOM.
130
+
131
+ **Loadbare and MDV:**
132
+
133
+ - `<template>` as the unit of repetition and of conditions.
134
+ - Built toward web standards, not a proprietary runtime.
135
+
136
+ **Loadbare and IE4:**
137
+
138
+ - A relational vocabulary: a record set, a single record, a column per
139
+ element.
140
+ - The row as the repetition template.
141
+ - SQL behind the data source.
142
+
143
+ **MDV and IE4, and not Loadbare:**
144
+
145
+ - The data lives in the browser.
146
+ - Two-way binding.
147
+ - The view keeps itself synchronized with changes to that data.
148
+
149
+ **MDV only:**
150
+
151
+ - Runtime `{{}}` placeholders and expressions.
152
+ - Paths into nested object trees.
153
+ - Change observation, and bindings that have to be closed.
154
+ - A false `if` destroys its instances.
155
+
156
+ **Loadbare only:**
157
+
158
+ - The server is the source of truth, and the hub holds no data.
159
+ - A response says what changed, as a whole list, a patch or a row, so nothing
160
+ is observed.
161
+ - Writes are requests (`lb-action` and the CRUD operations) whose answers land
162
+ back.
163
+ - A request's position is read from the document.
164
+ - A build step: expansion, tree shaking, pages shipped as templates.
165
+ - Navigation and request state carried by the hub.
166
+
167
+ Two of Loadbare's central decisions reject what ended MDV. There is no
168
+ client-side model to observe, which is what made `Object.observe` too slow in
169
+ practice. And data comes only as rows and sets of rows, never as the nested
170
+ object paths MDV bound to.
171
+
172
+ ## Conditional rendering elsewhere
173
+
174
+ Frameworks handle a false branch in one of two ways. Either it is hidden
175
+ with CSS and keeps its state, or it is removed and rebuilt from scratch when
176
+ it returns. A few keep a removed branch alive in framework memory.
177
+
178
+ | Framework | The false branch | State kept | Updated while hidden |
179
+ |----------------------------------|-----------------------------------------------------------------------------------|------------|----------------------|
180
+ | MDV `<template if>` | Instances removed after the template, bindings closed | no | no |
181
+ | Alpine `<template x-if>` | Cloned from the template and inserted after it on show, destroyed and removed on hide | no | no |
182
+ | Knockout `if` | Comment nodes mark the place, contents re-rendered completely | no | no |
183
+ | Angular `*ngIf` | `<ng-template>` rendered as a comment anchor; a view can be detached and reinserted | if detached | no |
184
+ | Aurelia `if.bind` | Removed from the DOM, views cached by default and reused | yes | not documented |
185
+ | Vue `<KeepAlive>` | Detached from the document but not unmounted | yes | no |
186
+ | Lit `cache()` | DOM kept in a `DocumentFragment`, swapped back in | yes | on swap-in |
187
+ | Polymer `dom-if` | `style.display = 'none'`; `restamp` destroys and re-creates instead | yes | yes |
188
+ | React `<Activity mode="hidden">` | `display: none`, Effects destroyed | yes | yes, at lower priority |
189
+
190
+ Loadbare's `lb-show` moves the live element into a `<template>` that takes
191
+ its place, and landing still reaches it there. Each
192
+ part has precedent: templates as conditions (MDV, Alpine, Angular), branches
193
+ kept rather than rebuilt (Aurelia, Angular, Vue), and hidden branches kept
194
+ current (Polymer, React). No source found keeps the branch in a template in
195
+ the document, standing where the element stood, with no framework cache. The
196
+ hub has nowhere else to keep one.
197
+
198
+ Loadbare's recommendation before `lb-show`, a stylesheet rule on `lb-value`,
199
+ is the same family as Polymer's `dom-if` and MDV's `hidden?`: the element stays and
200
+ CSS hides it.
201
+
202
+ Sources:
203
+ [Alpine x-if source](https://raw.githubusercontent.com/alpinejs/alpine/main/packages/alpinejs/src/directives/x-if.js),
204
+ [Alpine x-if](https://alpinejs.dev/directives/if),
205
+ [Knockout virtual elements](https://knockoutjs.com/documentation/custom-bindings-for-virtual-elements.html),
206
+ [Knockout if/with re-rendering](https://www.knockmeout.net/2012/03/knockoutjs-performance-gotcha-1ifwith.html),
207
+ [Angular NgIf](https://angular.dev/api/common/NgIf),
208
+ [Reusing views in Angular](https://angular.love/optimization-techniques-reusing-views/),
209
+ [Aurelia conditional rendering](https://docs.aurelia.io/templates/conditional-rendering),
210
+ [Vue KeepAlive](https://vuejs.org/guide/built-ins/keep-alive.html),
211
+ [Lit directives](https://lit.dev/docs/templates/directives/),
212
+ [Lit cache.ts](https://github.com/lit/lit/blob/lit-html-1.x/src/directives/cache.ts),
213
+ [Polymer dom-if](https://polymer-library.polymer-project.org/2.0/docs/devguide/templates),
214
+ [Polymer display caching](https://github.com/Polymer/polymer/commit/2611285),
215
+ [Polymer issue #2712](https://github.com/Polymer/polymer/issues/2712),
216
+ [React Activity](https://react.dev/reference/react/Activity).
@@ -223,6 +223,7 @@ as a string literal.
223
223
  |------------------|------------|
224
224
  | `ATTR_VALUE` | `lb-value` |
225
225
  | `ATTR_CELL` | `lb-cell` |
226
+ | `ATTR_SHOW` | `lb-show` |
226
227
  | `ATTR_LIST` | `lb-list` |
227
228
  | `ATTR_ROW` | `lb-row` |
228
229
  | `ATTR_KEY` | `lb-key` |
@@ -260,6 +261,15 @@ cells a successful insert resets — see
260
261
  [TECHREF-1.0](../TECHREF-1.0.md#the-round-trip). Read it as nothing landed,
261
262
  and show the widget's default. A blank string is a value that landed.
262
263
 
264
+ A widget carrying `lb-show`, or inside an element that does, is moved into a
265
+ template while its column is off and back out when it turns on — see
266
+ [Conditional rendering](./data-binding.md#conditional-rendering). Going in, it
267
+ sees `disconnectedCallback` and then `adoptedCallback`; coming out,
268
+ `adoptedCallback` and then `connectedCallback`. It is the same instance
269
+ throughout, and it still receives `lb-value` while it is away, so write
270
+ `connectedCallback` to run more than once, as a row a list reorders already
271
+ requires.
272
+
263
273
  List `ATTR_VALUE` in `observedAttributes`, or `attributeChangedCallback`
264
274
  never fires. The browser calls it for an attribute already present when an
265
275
  element upgrades, not only for one that changes afterward, so a widget's
@@ -41,14 +41,15 @@ asks for are declared on the server; see [page files](./page-files.md).
41
41
 
42
42
  ## Binding
43
43
 
44
- | Attribute | Written by | Names |
45
- |----------------|-------------|-------------------------------------------|
46
- | `lb-list` | a developer | The set of rows a subtree displays |
47
- | `lb-row` | a developer | The one row a subtree displays |
48
- | `lb-key` | a developer | The column that identifies a row |
49
- | `lb-cell` | a developer | The column an element displays |
50
- | `lb-key-value` | the hub | A live row's own key |
51
- | `lb-value` | the hub | The value that landed on a cell |
44
+ | Attribute | Written by | Names |
45
+ |----------------|-------------|-------------------------------------------------------|
46
+ | `lb-list` | a developer | The set of rows a subtree displays |
47
+ | `lb-row` | a developer | The one row a subtree displays |
48
+ | `lb-key` | a developer | The column that identifies a row |
49
+ | `lb-cell` | a developer | The column an element displays |
50
+ | `lb-show` | a developer | The column that decides whether an element is present |
51
+ | `lb-key-value` | the hub | A live row's own key |
52
+ | `lb-value` | the hub | The value that landed on a cell |
52
53
 
53
54
  A binding is scoped by ancestry. Either scope attribute scopes its DOM
54
55
  children, and a nested one of either kind begins a new scope, so an element
@@ -283,42 +284,91 @@ gathers the same way; see
283
284
 
284
285
  Loadbare ships static HTML and hydrates elements that are already in the
285
286
  document. There is no `if`, and none is needed: write every possibility into
286
- the page, and control which of them is showing.
287
+ the page, and let a column decide which of them is present.
287
288
 
288
- Every cell carries the value that landed on it as `lb-value`, so a
289
- stylesheet can show or hide part of a page from a value the server sent. Bind
290
- a column the page does not display to a hidden element:
289
+ Write `lb-show` on an element, naming the column that decides it:
291
290
 
292
291
  ```html
293
292
  <template lb-key="id">
294
293
  <tr>
295
294
  <td lb-cell="name"></td>
296
- <td lb-cell="locked" hidden></td>
297
- <td><button lb-action="lb-row-delete">Remove</button></td>
295
+ <td><button lb-action="lb-row-delete" lb-show="removable">Remove</button></td>
298
296
  </tr>
299
297
  </template>
300
298
  ```
301
299
 
302
- ```css
303
- tr:has([lb-cell="locked"][lb-value="true"]) button {
304
- display: none;
305
- }
300
+ ```sql
301
+ (ledger_count = 0 AND system_behavior IS NULL) AS removable
306
302
  ```
307
303
 
308
- `lb-value` holds the string the query sent, so the query decides the spelling
309
- the selector matches. A stylesheet can hide a control but cannot disable one,
310
- and hiding is presentation: the server still refuses what a request may not
311
- do.
304
+ A value of `null` or `false` takes the element out of the page, and any other
305
+ value puts it back. The hub never reads a string, so `"false"` is a value like
306
+ any other: have the query answer with a boolean or a null. A row that does not
307
+ carry the column leaves the element as it is, so a query that answers with
308
+ whole rows returns the column in every row.
312
309
 
313
- Where showing a case takes more than a selector, a widget receives the value
314
- in `lb-value` and decides what to show:
310
+ `lb-show` binds the way `lb-cell` does, to the row on its nearest scoped
311
+ ancestor. On an element that is itself a scope, the column belongs to the
312
+ row around it, so this picker takes its choices from `groups` and whether it
313
+ is present from the account row:
315
314
 
316
- ```ts
317
- for (const step of steps) step.hidden = step.dataset.step !== value;
315
+ ```html
316
+ <select lb-list="groups" lb-cell="group_id" lb-show="group_choice">
318
317
  ```
319
318
 
320
- Ship the case that is showing on arrival unhidden, and hide the rest in the
321
- HTML.
319
+ An element may show a column and be decided by it, which shows a note only
320
+ when there is one:
321
+
322
+ ```html
323
+ <span lb-cell="note" lb-show="note"></span>
324
+ ```
325
+
326
+ An element that is not present cannot be clicked, but that is presentation:
327
+ the server still refuses what a request may not do.
328
+
329
+ ### Where an absent element is
330
+
331
+ An element whose column is off is moved into a `<template lb-show>` that
332
+ stands where it stood, and moved back out when the column turns on. The
333
+ developer never writes that template.
334
+
335
+ - Nothing renders it, whatever a stylesheet says, because a template's content
336
+ is not its children.
337
+ - It cannot be focused or clicked, assistive technology does not announce it,
338
+ and a form does not gather it.
339
+ - It is moved, never rebuilt, so a widget keeps its instance and a control
340
+ keeps what was typed into it.
341
+ - Values keep landing on it, and on every cell and scope inside it, while it
342
+ is away, so it returns current.
343
+
344
+ The builder ships every `lb-show` element already inside its template, so
345
+ nothing conditional shows until its row has landed.
346
+
347
+ A condition never changes the structure of a page. An absent element keeps
348
+ its place among its siblings, so a position selector (`:first-child`,
349
+ `:nth-child`, `:empty`, `+`, `~`) counts its template as a sibling. A selector
350
+ by tag, class or attribute is unaffected. Only a list changes a page's
351
+ structure.
352
+
353
+ A condition that is only a style is a class on an element that is present or
354
+ not:
355
+
356
+ ```html
357
+ <span lb-show="out_of_balance" class="danger">Out of balance</span>
358
+ ```
359
+
360
+ These are build errors:
361
+
362
+ - `lb-show` on a row template's root. A row that should not show is left out
363
+ by the query.
364
+ - `lb-show` with no row around it: outside every scope, on a scope with none
365
+ around it, or in a list scope outside its row template, where nothing lands.
366
+ - `lb-show` on a `<template>`.
367
+
368
+ A condition that is not data, such as a collapsed section or an open menu,
369
+ has no column. Use `<details>`, a stylesheet, or a widget. Every cell still
370
+ carries the value that landed on it as `lb-value`, for a widget to read or a
371
+ stylesheet to select on.
322
372
 
323
373
  ### An empty list
324
374
 
@@ -369,6 +419,12 @@ button in a stylesheet, or have a widget watch its own attributes and
369
419
  disable itself. An application that styles neither behaves correctly and
370
420
  shows nothing.
371
421
 
422
+ A native button or form pressed again while it carries `lb-pending` is
423
+ ignored, so a pending one is already disabled and the stylesheet only shows
424
+ it. A widget is not held back, since one that sends on change must send its
425
+ latest value. The hub also sets `aria-busy="true"` for as long as
426
+ `lb-pending` is present.
427
+
372
428
  ## Sending a request from a widget
373
429
 
374
430
  A widget can build and dispatch a request itself instead of carrying one of
package/docs/testing.md CHANGED
@@ -194,6 +194,8 @@ What the hub is tested for here:
194
194
  of the four, is refused before it reaches the wire
195
195
  - `lb-pending` lands on the element that dispatched, `lb-error` replaces it
196
196
  on failure, and the next request clears it
197
+ - `aria-busy` comes and goes with `lb-pending`; a native button or form
198
+ performed again while pending sends nothing, and a widget still sends
197
199
  - a path with no page host reports and opens the unknown-page dialog; two
198
200
  hosts for one name report and take the first
199
201
  - `lb-navigation` lands with the path and the label of the link that names it