@webqit/oohtml 2.1.77 → 2.1.79
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.
- package/README.md +24 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,22 +71,6 @@ let { user } = document.namespace;
|
|
|
71
71
|
let { url, name, email } = user.namespace;
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
<details><summary>Learn more</summary>
|
|
75
|
-
|
|
76
|
-
You want to see how IDs are otherwise exposed as global variables:
|
|
77
|
-
|
|
78
|
-
```html
|
|
79
|
-
<div id="foo"><div>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
console.log(window.foo); // div
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
[Read more](https://stackoverflow.com/questions/6381425/is-there-a-spec-that-the-id-of-elements-should-be-made-global-variable)
|
|
87
|
-
|
|
88
|
-
</details>
|
|
89
|
-
|
|
90
74
|
<details><summary>All in Realtime</summary>
|
|
91
75
|
|
|
92
76
|
The Namespace API is designed to always reflect the DOM in real-time. This may be observed using the general-purpose object observability API - [Observer API](https://github.com/webqit/observer):
|
|
@@ -118,6 +102,22 @@ function changeCallback(changes) {
|
|
|
118
102
|
|
|
119
103
|
</details>
|
|
120
104
|
|
|
105
|
+
<details><summary>Learn more</summary>
|
|
106
|
+
|
|
107
|
+
You want to see how IDs are otherwise exposed as global variables:
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<div id="foo"><div>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
console.log(window.foo); // div
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
[Read more](https://stackoverflow.com/questions/6381425/is-there-a-spec-that-the-id-of-elements-should-be-made-global-variable)
|
|
118
|
+
|
|
119
|
+
</details>
|
|
120
|
+
|
|
121
121
|
### Scoping
|
|
122
122
|
|
|
123
123
|
We often need a way to keep things like styles and scripts [scoped to a component](https://vuejs.org/guide/scaling-up/sfc.html).
|
|
@@ -144,8 +144,6 @@ Here, we get the `scoped` attribute for *scoping* said element-specific styleshe
|
|
|
144
144
|
let { styleSheets, scripts } = user; // APIs that are analogous to the document.styleSheets, document.scripts properties
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
└ [Modular HTML examples](#modular-html-examples)
|
|
148
|
-
|
|
149
147
|
## HTML Imports
|
|
150
148
|
|
|
151
149
|
HTML Imports is a realtime module system for HTML written in HTML! Something like it is the [`<defs>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs) and [`<use>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use) system in SVG.
|
|
@@ -154,7 +152,7 @@ OOHTML makes this possible in just simple conventions - via a new `def` attribut
|
|
|
154
152
|
|
|
155
153
|
### Module Definition
|
|
156
154
|
|
|
157
|
-
A module here is any piece of markup that
|
|
155
|
+
A module here is any piece of markup that can be reused.
|
|
158
156
|
|
|
159
157
|
Here, we get the `def` attribute for defining those - either as whole *module* or as *fragment*:
|
|
160
158
|
|
|
@@ -239,9 +237,9 @@ Here, we get an `<import>` element that lets us do that declaratively:
|
|
|
239
237
|
|
|
240
238
|
<details><summary>All in Realtime</summary>
|
|
241
239
|
|
|
242
|
-
As a realtime module system, `<import> `elements maintain a live relationship with given module definition `<template def>`
|
|
240
|
+
As a realtime module system, `<import> `elements maintain a live relationship with given module definition elements (`<template def>`) and are resolved again in the event that:
|
|
243
241
|
+ the `<import>` element points to another module — either by `ref` change or by a change in `importscontext` (below).
|
|
244
|
-
+ the module definition `<template def>`
|
|
242
|
+
+ the module definition element (`<template def>`) has had its contents updated, either programmatically or automatically from having loaded.
|
|
245
243
|
|
|
246
244
|
Conversely, an `<import>` element that has been resolved will self-restore in the event that:
|
|
247
245
|
+ the `<import>` element no longer points to a module; or the module has been emptied or removed.
|
|
@@ -264,7 +262,7 @@ The above resolved imports would thus give us something like:
|
|
|
264
262
|
</body>
|
|
265
263
|
```
|
|
266
264
|
|
|
267
|
-
But they also
|
|
265
|
+
But they also would need to remember the exact imported nodes that they manage so as to be able to re-establish that relationship on getting to the client. This information is automatically encoded as part of the serialised element itself, in something like:
|
|
268
266
|
|
|
269
267
|
```html
|
|
270
268
|
<!--<import ref="/foo/nested#fragment2" nodecount="1"></import>-->
|
|
@@ -364,7 +362,7 @@ setTimeout(() => abortController.abort(), 1000);
|
|
|
364
362
|
|
|
365
363
|
We can defer module loading until we really need them.
|
|
366
364
|
|
|
367
|
-
Here, we get the `loading="lazy"` directive for that:
|
|
365
|
+
Here, we get the `loading="lazy"` directive for that; and loading is only then triggered on the first attempt to import its contents:
|
|
368
366
|
|
|
369
367
|
```html
|
|
370
368
|
<!-- Loading doesn't happen until the first time this is being accessed -->
|
|
@@ -382,7 +380,7 @@ const moduleObject2 = document.import('/foo#fragment1'); // Triggers module load
|
|
|
382
380
|
|
|
383
381
|
### Scoped Modules
|
|
384
382
|
|
|
385
|
-
Some modules will only be relevant within a specific context in the page.
|
|
383
|
+
Some modules will only be relevant within a specific context in the page, and these shouldn't map to the global document scope.
|
|
386
384
|
|
|
387
385
|
Here, we get the `scoped` attribute for scoping those to their respective contexts, and thus, implicitly have an *object-scoped* module system:
|
|
388
386
|
|
|
@@ -566,8 +564,6 @@ console.log(localOrGlobalImport2); // { value: div }
|
|
|
566
564
|
|
|
567
565
|
</details>
|
|
568
566
|
|
|
569
|
-
└ [HTML Imports examples](#html-imports-examples)
|
|
570
|
-
|
|
571
567
|
## Data Binding
|
|
572
568
|
|
|
573
569
|
Data binding is the concept of having a mechanism that declaratively drives the UI from application data, ensuring that the relevant parts of the UI are *automatically* updated as application state changes.
|
|
@@ -576,7 +572,7 @@ OOHTML makes this possible in just simple conventions - via a new comment-based
|
|
|
576
572
|
|
|
577
573
|
### Discrete Data-Binding
|
|
578
574
|
|
|
579
|
-
Here, we get a comment-based data-binding
|
|
575
|
+
Here, we get a comment-based data-binding tag `<?{ }?>` which works like regular comment but stay "data-charged":
|
|
580
576
|
|
|
581
577
|
```js
|
|
582
578
|
<html>
|
|
@@ -596,7 +592,7 @@ On the server, these data-binding tags would retain their place in the DOM while
|
|
|
596
592
|
|
|
597
593
|
The following: `<?{ 'Hello World' }?>` would thus give us: `<?{ 'Hello World' }?>Hello World`.
|
|
598
594
|
|
|
599
|
-
But they also
|
|
595
|
+
But they also would need to remember the exact text node that they manage, so as to be able to re-establish that relationship on getting to the client. That information is automatically encoded as part of the declaration itself, and that brings us to having a typical server-rendered binding look like this:
|
|
600
596
|
|
|
601
597
|
```html
|
|
602
598
|
<?{ 'Hello World'; [=11] }?>Hello World
|