@webqit/oohtml 3.0.1-2 → 3.0.1-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.
- package/README.md +39 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -651,7 +651,7 @@ Here, we get the `binding` attribute for a declarative and neat, key/value data-
|
|
|
651
651
|
| `%` | Class Name | `<div binding="% active:app.isActive; % expanded:app.isExpanded;"></div>` |
|
|
652
652
|
| `~` | Attribute Name | `<a binding="~ href:person.profileUrl+'#bio'; ~ title:'Click me';"></a>` |
|
|
653
653
|
| | Boolean Attribute | `<a binding="~ ?required:formField.required; ~ ?aria-checked: formField.checked"></a>` |
|
|
654
|
-
| `@` | Structural Directive: | *See
|
|
654
|
+
| `@` | Structural Directive: | *See below* |
|
|
655
655
|
| `@text` | Plain text content | `<span binding="@text:firstName+' '+lastName;"></span>` |
|
|
656
656
|
| `@html` | Markup content | `<span binding="@html: '<i>'+firstName+'</i>';"></span>` |
|
|
657
657
|
| `@items` | A list, with argument in the following format:<br>`<declaration> <of\|in> <iterable> / <importRef>` | *See next two tables* |
|
|
@@ -690,9 +690,9 @@ Generated item elements are automatically assigned a corresponding index with a
|
|
|
690
690
|
|
|
691
691
|
### Quantum Scripts
|
|
692
692
|
|
|
693
|
-
We often still need to write more serious reactive logic on the UI than a declarative data-binding language can provide. But we shouldn't need to reach for special tooling or some "serious" programming paradigm on top of JavaScript.
|
|
693
|
+
We often still need to write more serious reactive logic on the UI than a declarative data-binding language can provide for. But we shouldn't need to reach for special tooling or some "serious" programming paradigm on top of JavaScript.
|
|
694
694
|
|
|
695
|
-
Here, from the same `<script>` element we write
|
|
695
|
+
Here, from the same `<script>` element we already write, we get a direct upgrade path to reactive programming in just an attribute: `quantum`:
|
|
696
696
|
|
|
697
697
|
```html
|
|
698
698
|
<script quantum>
|
|
@@ -732,7 +732,7 @@ Here, from the same `<script>` element we write everyday, we get a direct upgrad
|
|
|
732
732
|
</main>
|
|
733
733
|
```
|
|
734
734
|
|
|
735
|
-
**-->** *with content being whatever you normally would write in a `<script>` element*:
|
|
735
|
+
**-->** *with content being whatever you normally would write in a `<script>` element, but without the "manual" work for reactivity*:
|
|
736
736
|
|
|
737
737
|
```html
|
|
738
738
|
<main>
|
|
@@ -750,15 +750,48 @@ Here, from the same `<script>` element we write everyday, we get a direct upgrad
|
|
|
750
750
|
</main>
|
|
751
751
|
```
|
|
752
752
|
|
|
753
|
+
**-->** *within which other "live" APIs, like the Namespace API above, fit seamlessly*:
|
|
754
|
+
|
|
755
|
+
```html
|
|
756
|
+
<main namespace>
|
|
757
|
+
|
|
758
|
+
<script scoped quantum>
|
|
759
|
+
if (this.namespace.specialButton) {
|
|
760
|
+
console.log('specialButton present!');
|
|
761
|
+
} else {
|
|
762
|
+
console.log('specialButton not present!');
|
|
763
|
+
}
|
|
764
|
+
let specialButton = this.namespace.specialButton;
|
|
765
|
+
console.log(specialButton);
|
|
766
|
+
</script>
|
|
767
|
+
|
|
768
|
+
</main>
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
```js
|
|
772
|
+
const main = document.querySelector('main');
|
|
773
|
+
const button = document.createElement('button');
|
|
774
|
+
button.id = 'specialButton';
|
|
775
|
+
|
|
776
|
+
const addButton = () => {
|
|
777
|
+
main.appendChild(button);
|
|
778
|
+
setTimeout(removeButton, 5000);
|
|
779
|
+
};
|
|
780
|
+
const removeButton = () => {
|
|
781
|
+
button.remove();
|
|
782
|
+
setTimeout(addButton, 5000);
|
|
783
|
+
};
|
|
784
|
+
```
|
|
785
|
+
|
|
753
786
|
<details><summary>Details</summary>
|
|
754
787
|
|
|
755
788
|
It's Imperative Reactive Programming ([IRP](https://en.wikipedia.org/wiki/Reactive_programming#Imperative)) right there and it's the [Quantum](https://github.com/webqit/quantum-js) runtime extension to JavaScript!
|
|
756
789
|
|
|
757
790
|
Here, the runtime executes your code in a special execution mode that gets literal JavaScript expressions to statically reflect changes. This makes a lot of things possible on the UI! The [Quantum JS](https://github.com/webqit/quantum-js) documentation has a detailed run down.
|
|
758
791
|
|
|
759
|
-
Now, in each case above, reactivity
|
|
792
|
+
Now, in each case above, reactivity terminates on script's removal from the DOM. But of course, DOM event handlers bound via `addEventListener()` would still need to be terminated in their own way.
|
|
760
793
|
|
|
761
|
-
|
|
794
|
+
</details>
|
|
762
795
|
|
|
763
796
|
## Data Plumbing
|
|
764
797
|
|