@webqit/oohtml 2.1.74 → 2.1.76
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 +26 -49
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -572,9 +572,9 @@ console.log(localOrGlobalImport2); // { value: div }
|
|
|
572
572
|
|
|
573
573
|
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.
|
|
574
574
|
|
|
575
|
-
OOHTML makes this possible in just simple conventions - via a new comment-based data-binding syntax `<?{ }?>` and a complementary new `binding` attribute!
|
|
575
|
+
OOHTML makes this possible in just simple conventions - via a new comment-based data-binding syntax `<?{ }?>` and a complementary new `binding` attribute! And there's one more: Stateful Scripts which brings the most advanced form of reactivity to HTML!
|
|
576
576
|
|
|
577
|
-
###
|
|
577
|
+
### Discrete Data-Binding
|
|
578
578
|
|
|
579
579
|
Here, we get a comment-based data-binding syntax `<?{ }?>` which works like regular comment but stay "data-charged":
|
|
580
580
|
|
|
@@ -608,7 +608,7 @@ Now that extra bit of information gets decoded and original relationships are fo
|
|
|
608
608
|
|
|
609
609
|
</details>
|
|
610
610
|
|
|
611
|
-
###
|
|
611
|
+
### Inline Data-Binding
|
|
612
612
|
|
|
613
613
|
Here, we get the `binding` attribute for a declarative and neat, key/value data-binding syntax:
|
|
614
614
|
|
|
@@ -650,7 +650,7 @@ Here, we get the `binding` attribute for a declarative and neat, key/value data-
|
|
|
650
650
|
| `@html` | Markup content | `<span binding="@html: '<i>'+firstName+'</i>';"></span>` |
|
|
651
651
|
| `@items` | A list, with argument in the following format:<br>`<declaration> <of\|in> <iterable> / <importRef>` | *See next two tables* |
|
|
652
652
|
|
|
653
|
-
<details><summary
|
|
653
|
+
<details><summary><code>For ... Of</code> Loops</summary>
|
|
654
654
|
|
|
655
655
|
| Idea | Usage |
|
|
656
656
|
| :---- | :---- |
|
|
@@ -661,7 +661,7 @@ Here, we get the `binding` attribute for a declarative and neat, key/value data-
|
|
|
661
661
|
|
|
662
662
|
</details>
|
|
663
663
|
|
|
664
|
-
<details><summary
|
|
664
|
+
<details><summary><code>For ... In</code> Loops</summary>
|
|
665
665
|
|
|
666
666
|
| Idea | Usage |
|
|
667
667
|
| :---- | :---- |
|
|
@@ -682,25 +682,13 @@ Generated item elements are automatically assigned a corresponding index with a
|
|
|
682
682
|
|
|
683
683
|
</details>
|
|
684
684
|
|
|
685
|
-
|
|
685
|
+
### Stateful Scripts
|
|
686
686
|
|
|
687
|
-
|
|
688
|
-
<section>
|
|
689
|
-
|
|
690
|
-
<!-- The "items" template -->
|
|
691
|
-
<template def="item" scoped>
|
|
692
|
-
<li><a binding="~href: '/animals#'+name;"><?{ index+': '+name }?></a></li>
|
|
693
|
-
</template>
|
|
694
|
-
|
|
695
|
-
<!-- The loop -->
|
|
696
|
-
<ul binding="@items: (name,index) of ['dog','cat','ram'] / 'item';"></ul>
|
|
697
|
-
|
|
698
|
-
</section>
|
|
699
|
-
```
|
|
687
|
+
*[TODO]*
|
|
700
688
|
|
|
701
689
|
## Data Plumbing
|
|
702
690
|
|
|
703
|
-
*[TODO]:
|
|
691
|
+
*[TODO]: Bindings API & The Context API*
|
|
704
692
|
|
|
705
693
|
<!--
|
|
706
694
|
The last set of features covers the concept of "state", "bindings", and "reactivity" for those objects at the DOM level - in the most exciting form of the terms and as an upgrade path! This comes factored into the design as something intrinsic to the problem.
|
|
@@ -937,8 +925,8 @@ Here are a few examples in the wide range of use cases these features cover.
|
|
|
937
925
|
+ [Example 1: *Single Page Application*](#example-1-single-page-application)
|
|
938
926
|
+ [Example 2: *Multi-Level Namespacing*](#example-2-multi-level-namespacing)
|
|
939
927
|
+ [Example 3: *Dynamic Shadow DOM*](#example-3-dynamic-shadow-dom)
|
|
940
|
-
+ [Example 4: *
|
|
941
|
-
+ [Example 5: *
|
|
928
|
+
+ [Example 4: *Declarative Lists*](#example-4-declarative-lists)
|
|
929
|
+
+ [Example 5: *Imperative Lists*](#example-4-imperative-lists)
|
|
942
930
|
|
|
943
931
|
### Example 1: *Single Page Application*
|
|
944
932
|
|
|
@@ -1138,56 +1126,45 @@ The following is a custom element that derives its Shadow DOM from an imported `
|
|
|
1138
1126
|
|
|
1139
1127
|
</details>
|
|
1140
1128
|
|
|
1141
|
-
### Example 4: *
|
|
1129
|
+
### Example 4: *Declarative Lists*
|
|
1142
1130
|
|
|
1143
|
-
The following is a
|
|
1131
|
+
The following is a hypothetical list page!
|
|
1144
1132
|
|
|
1145
1133
|
<details><summary>Code</summary>
|
|
1146
1134
|
|
|
1147
1135
|
```html
|
|
1148
|
-
<
|
|
1149
|
-
|
|
1150
|
-
<ul id="list"></ul>
|
|
1136
|
+
<section>
|
|
1151
1137
|
|
|
1138
|
+
<!-- The "items" template -->
|
|
1152
1139
|
<template def="item" scoped>
|
|
1153
|
-
<li><a
|
|
1140
|
+
<li><a binding="~href: '/animals#'+name;"><?{ index+': '+name }?></a></li>
|
|
1154
1141
|
</template>
|
|
1155
1142
|
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
let itemImport = this.import('item');
|
|
1159
|
-
let itemTemplate = itemImport.value;
|
|
1160
|
-
|
|
1161
|
-
// Iterate
|
|
1162
|
-
[ 'Item 1', 'Item 2', 'Item 3' ].forEach(entry => {
|
|
1163
|
-
const currentItem = itemTemplate.content.cloneNode(true);
|
|
1164
|
-
// Add to DOM
|
|
1165
|
-
this.namespace.list.appendChild(currentItem);
|
|
1166
|
-
// Render
|
|
1167
|
-
currentItem.innerHTML = entry;
|
|
1168
|
-
});
|
|
1169
|
-
</script>
|
|
1143
|
+
<!-- The loop -->
|
|
1144
|
+
<ul binding="@items: (name,index) of ['dog','cat','ram'] / 'item';"></ul>
|
|
1170
1145
|
|
|
1171
|
-
</
|
|
1146
|
+
</section>
|
|
1172
1147
|
```
|
|
1173
1148
|
|
|
1174
1149
|
</details>
|
|
1175
1150
|
|
|
1176
|
-
### Example 4: *
|
|
1151
|
+
### Example 4: *Imperative Lists*
|
|
1177
1152
|
|
|
1178
|
-
The following is
|
|
1153
|
+
The following is much like the above, but imperative. Additions and removals on the data items are also statically reflected!
|
|
1179
1154
|
|
|
1180
1155
|
<details><summary>Code</summary>
|
|
1181
1156
|
|
|
1182
1157
|
```html
|
|
1183
|
-
<
|
|
1184
|
-
|
|
1185
|
-
<ul id="list"></ul>
|
|
1158
|
+
<section namespace>
|
|
1186
1159
|
|
|
1160
|
+
<!-- The "items" template -->
|
|
1187
1161
|
<template def="item" scoped>
|
|
1188
1162
|
<li><a>Item</a></li>
|
|
1189
1163
|
</template>
|
|
1190
1164
|
|
|
1165
|
+
<!-- The loop -->
|
|
1166
|
+
<ul id="list"></ul>
|
|
1167
|
+
|
|
1191
1168
|
<script scoped>
|
|
1192
1169
|
// Import item template
|
|
1193
1170
|
let itemImport = this.import('item');
|
|
@@ -1214,7 +1191,7 @@ The following is the same list as above but implemented as a live list! Here, we
|
|
|
1214
1191
|
setTimeout(() => items.pop(), 2000);
|
|
1215
1192
|
</script>
|
|
1216
1193
|
|
|
1217
|
-
</
|
|
1194
|
+
</section>
|
|
1218
1195
|
```
|
|
1219
1196
|
|
|
1220
1197
|
</details>
|