@webqit/oohtml 3.0.1-0 → 3.0.1-2

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.
Files changed (2) hide show
  1. package/README.md +82 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -38,13 +38,13 @@ This project pursues an object-oriented approach to HTML and implicitly revisits
38
38
 
39
39
  ## Modular HTML
40
40
 
41
- Modular HTML is a markup pattern that lets us write arbitrary markup as self-contained objects - with each *encapsulating* its own structure, styling and logic - as against the regular idea of having everything converge and conflict on one global scope!
41
+ Modular HTML is a markup pattern that lets us write arbitrary markup as self-contained objects - with each *encapsulating* their own structure, styling and logic!
42
42
 
43
43
  OOHTML makes this possible in just simple conventions - via two new attributes: `namespace` and `scoped`!
44
44
 
45
45
  ### Namespacing
46
46
 
47
- Naming things is hard! That's especially so where there's one global namespace and a miriad of potential conflicts - as is the case with HTML!
47
+ Naming things is hard! That's especially so where you have one global namespace and a miriad of potentially conflicting names to coordinate!
48
48
 
49
49
  Here, we get the `namespace` attribute for designating an element as own naming context for identifiers instead of the global namespace:
50
50
 
@@ -148,9 +148,18 @@ Here, we get the `scoped` attribute for *scoping* said element-specific styleshe
148
148
  let { styleSheets, scripts } = user; // APIs that are analogous to the document.styleSheets, document.scripts properties
149
149
  ```
150
150
 
151
+ <details><summary>Learn more</summary>
152
+
153
+ The `scoped` has two effects on the `<script>` element:
154
+
155
+ + The `this` keyword is a reference to the script's host element
156
+ + The `<script>` element is executed again on each re-insertion to the DOM
157
+
158
+ </details>
159
+
151
160
  ## HTML Imports
152
161
 
153
- 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.
162
+ HTML Imports is a realtime module system for HTML that speaks 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
163
 
155
164
  OOHTML makes this possible in just simple conventions - via a new `def` attribute and a complementary new `<import>` element!
156
165
 
@@ -570,7 +579,7 @@ console.log(localOrGlobalImport2); // { value: div }
570
579
 
571
580
  ## Data Binding
572
581
 
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.
582
+ Data binding is about declaratively binding the UI to application data, ensuring that the relevant parts of the UI are *automatically* updated as application state changes.
574
583
 
575
584
  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: Quantum Scripts which brings the most advanced form of reactivity to HTML!
576
585
 
@@ -681,7 +690,75 @@ Generated item elements are automatically assigned a corresponding index with a
681
690
 
682
691
  ### Quantum Scripts
683
692
 
684
- *[TODO]*
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.
694
+
695
+ Here, from the same `<script>` element we write everyday, we get a direct upgrade path to reactive programming in just an attribute: `quantum`:
696
+
697
+ ```html
698
+ <script quantum>
699
+ // Code here
700
+ console.log(this); // window
701
+ </script>
702
+ ```
703
+
704
+ ```html
705
+ <script type="module" quantum>
706
+ // Code here
707
+ console.log(this); // undefined
708
+ </script>
709
+ ```
710
+
711
+ **-->** *which adds up really well with the idea of scoping*:
712
+
713
+ ```html
714
+ <main>
715
+
716
+ <script scoped quantum>
717
+ // Code here
718
+ console.log(this); // main
719
+ </script>
720
+
721
+ </main>
722
+ ```
723
+
724
+ ```html
725
+ <main>
726
+
727
+ <script type="module" scoped quantum>
728
+ // Code here
729
+ console.log(this); // main
730
+ </script>
731
+
732
+ </main>
733
+ ```
734
+
735
+ **-->** *with content being whatever you normally would write in a `<script>` element*:
736
+
737
+ ```html
738
+ <main>
739
+
740
+ <script type="module" scoped quantum>
741
+ import { someAPI } from 'some-module';
742
+
743
+ let clickCount = 0;
744
+ console.log(clickCount);
745
+ someAPI(clickCount);
746
+
747
+ this.addEventListener('click', e => clickCount++);
748
+ </script>
749
+
750
+ </main>
751
+ ```
752
+
753
+ <details><summary>Details</summary>
754
+
755
+ 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
+
757
+ 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
+
759
+ Now, in each case above, reactivity is stopped on script's removal from the DOM.
760
+
761
+ <details>
685
762
 
686
763
  ## Data Plumbing
687
764
 
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "3.0.1-0",
17
+ "version": "3.0.1-2",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",