@webqit/oohtml 2.1.75 → 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 +24 -45
- 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
|
|
|
@@ -682,23 +682,13 @@ Generated item elements are automatically assigned a corresponding index with a
|
|
|
682
682
|
|
|
683
683
|
</details>
|
|
684
684
|
|
|
685
|
-
|
|
686
|
-
<section>
|
|
685
|
+
### Stateful Scripts
|
|
687
686
|
|
|
688
|
-
|
|
689
|
-
<template def="item" scoped>
|
|
690
|
-
<li><a binding="~href: '/animals#'+name;"><?{ index+': '+name }?></a></li>
|
|
691
|
-
</template>
|
|
692
|
-
|
|
693
|
-
<!-- The loop -->
|
|
694
|
-
<ul binding="@items: (name,index) of ['dog','cat','ram'] / 'item';"></ul>
|
|
695
|
-
|
|
696
|
-
</section>
|
|
697
|
-
```
|
|
687
|
+
*[TODO]*
|
|
698
688
|
|
|
699
689
|
## Data Plumbing
|
|
700
690
|
|
|
701
|
-
*[TODO]:
|
|
691
|
+
*[TODO]: Bindings API & The Context API*
|
|
702
692
|
|
|
703
693
|
<!--
|
|
704
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.
|
|
@@ -935,8 +925,8 @@ Here are a few examples in the wide range of use cases these features cover.
|
|
|
935
925
|
+ [Example 1: *Single Page Application*](#example-1-single-page-application)
|
|
936
926
|
+ [Example 2: *Multi-Level Namespacing*](#example-2-multi-level-namespacing)
|
|
937
927
|
+ [Example 3: *Dynamic Shadow DOM*](#example-3-dynamic-shadow-dom)
|
|
938
|
-
+ [Example 4: *
|
|
939
|
-
+ [Example 5: *
|
|
928
|
+
+ [Example 4: *Declarative Lists*](#example-4-declarative-lists)
|
|
929
|
+
+ [Example 5: *Imperative Lists*](#example-4-imperative-lists)
|
|
940
930
|
|
|
941
931
|
### Example 1: *Single Page Application*
|
|
942
932
|
|
|
@@ -1136,56 +1126,45 @@ The following is a custom element that derives its Shadow DOM from an imported `
|
|
|
1136
1126
|
|
|
1137
1127
|
</details>
|
|
1138
1128
|
|
|
1139
|
-
### Example 4: *
|
|
1129
|
+
### Example 4: *Declarative Lists*
|
|
1140
1130
|
|
|
1141
|
-
The following is a
|
|
1131
|
+
The following is a hypothetical list page!
|
|
1142
1132
|
|
|
1143
1133
|
<details><summary>Code</summary>
|
|
1144
1134
|
|
|
1145
1135
|
```html
|
|
1146
|
-
<
|
|
1147
|
-
|
|
1148
|
-
<ul id="list"></ul>
|
|
1136
|
+
<section>
|
|
1149
1137
|
|
|
1138
|
+
<!-- The "items" template -->
|
|
1150
1139
|
<template def="item" scoped>
|
|
1151
|
-
<li><a
|
|
1140
|
+
<li><a binding="~href: '/animals#'+name;"><?{ index+': '+name }?></a></li>
|
|
1152
1141
|
</template>
|
|
1153
1142
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
let itemImport = this.import('item');
|
|
1157
|
-
let itemTemplate = itemImport.value;
|
|
1158
|
-
|
|
1159
|
-
// Iterate
|
|
1160
|
-
[ 'Item 1', 'Item 2', 'Item 3' ].forEach(entry => {
|
|
1161
|
-
const currentItem = itemTemplate.content.cloneNode(true);
|
|
1162
|
-
// Add to DOM
|
|
1163
|
-
this.namespace.list.appendChild(currentItem);
|
|
1164
|
-
// Render
|
|
1165
|
-
currentItem.innerHTML = entry;
|
|
1166
|
-
});
|
|
1167
|
-
</script>
|
|
1143
|
+
<!-- The loop -->
|
|
1144
|
+
<ul binding="@items: (name,index) of ['dog','cat','ram'] / 'item';"></ul>
|
|
1168
1145
|
|
|
1169
|
-
</
|
|
1146
|
+
</section>
|
|
1170
1147
|
```
|
|
1171
1148
|
|
|
1172
1149
|
</details>
|
|
1173
1150
|
|
|
1174
|
-
### Example 4: *
|
|
1151
|
+
### Example 4: *Imperative Lists*
|
|
1175
1152
|
|
|
1176
|
-
The following is
|
|
1153
|
+
The following is much like the above, but imperative. Additions and removals on the data items are also statically reflected!
|
|
1177
1154
|
|
|
1178
1155
|
<details><summary>Code</summary>
|
|
1179
1156
|
|
|
1180
1157
|
```html
|
|
1181
|
-
<
|
|
1182
|
-
|
|
1183
|
-
<ul id="list"></ul>
|
|
1158
|
+
<section namespace>
|
|
1184
1159
|
|
|
1160
|
+
<!-- The "items" template -->
|
|
1185
1161
|
<template def="item" scoped>
|
|
1186
1162
|
<li><a>Item</a></li>
|
|
1187
1163
|
</template>
|
|
1188
1164
|
|
|
1165
|
+
<!-- The loop -->
|
|
1166
|
+
<ul id="list"></ul>
|
|
1167
|
+
|
|
1189
1168
|
<script scoped>
|
|
1190
1169
|
// Import item template
|
|
1191
1170
|
let itemImport = this.import('item');
|
|
@@ -1212,7 +1191,7 @@ The following is the same list as above but implemented as a live list! Here, we
|
|
|
1212
1191
|
setTimeout(() => items.pop(), 2000);
|
|
1213
1192
|
</script>
|
|
1214
1193
|
|
|
1215
|
-
</
|
|
1194
|
+
</section>
|
|
1216
1195
|
```
|
|
1217
1196
|
|
|
1218
1197
|
</details>
|