solarite 0.5.2 → 0.7.1
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/LICENSE +21 -0
- package/dist/Solarite-debug.js +4847 -3878
- package/dist/Solarite.js +4583 -3626
- package/dist/Solarite.min.js +2 -4
- package/package.json +19 -6
- package/readme.md +58 -11
- package/src/Globals.js +54 -72
- package/src/HtmlParser.js +90 -90
- package/src/MultiValueMap.js +57 -105
- package/src/NodeGroup.js +624 -470
- package/src/Path.js +224 -211
- package/src/PathToAttribValue.js +401 -261
- package/src/PathToAttribs.js +113 -80
- package/src/PathToComment.js +7 -7
- package/src/PathToComponent.js +183 -188
- package/src/PathToEvent.js +76 -64
- package/src/PathToKey.js +19 -0
- package/src/PathToNodes.js +1053 -566
- package/src/RootNodeGroup.js +120 -8
- package/src/Shell.js +570 -348
- package/src/Solarite.d.ts +134 -113
- package/src/Solarite.js +243 -286
- package/src/Template.js +195 -274
- package/src/Util.js +353 -351
- package/src/assert.js +10 -10
- package/src/assignAttributes.js +63 -0
- package/src/delve.js +55 -43
- package/src/h.js +220 -138
- package/src/jsx-dev-runtime.d.ts +1 -0
- package/src/jsx-dev-runtime.js +5 -0
- package/src/jsx-runtime.d.ts +21 -0
- package/src/jsx-runtime.js +84 -0
- package/src/jsx.js +194 -0
- package/src/toEl.js +77 -82
- package/dist/udomdiff-license.txt +0 -18
- package/src/getArg.js +0 -137
- package/src/hash.js +0 -89
- package/src/udomdiff.js +0 -176
- package/src/unused/FastLookupArray.js +0 -54
- package/src/unused/Hashes.js +0 -339
- package/src/unused/InUse.test.js +0 -92
- package/src/unused/InUseMap.js +0 -98
- package/src/unused/LinkedList.js +0 -117
- package/src/unused/LinkedList.test.js +0 -115
- package/src/unused/Misc.js +0 -13
- package/src/unused/Perf.js +0 -47
- package/src/unused/TrackedArray.js +0 -54
- package/src/unused/WeakArray.js +0 -33
- package/src/watch.js +0 -543
package/src/PathToEvent.js
CHANGED
|
@@ -1,65 +1,77 @@
|
|
|
1
|
-
import assert from "./assert.js";
|
|
2
|
-
import PathToAttribValue from "./PathToAttribValue.js";
|
|
3
|
-
|
|
4
|
-
// TODO: Merge this into PathToAttribValue?
|
|
5
|
-
export default class PathToEvent extends PathToAttribValue {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
import assert from "./assert.js";
|
|
2
|
+
import PathToAttribValue from "./PathToAttribValue.js";
|
|
3
|
+
|
|
4
|
+
// TODO: Merge this into PathToAttribValue?
|
|
5
|
+
export default class PathToEvent extends PathToAttribValue {
|
|
6
|
+
|
|
7
|
+
/** @type {string} The attrName without the "on" prefix. */
|
|
8
|
+
eventName;
|
|
9
|
+
|
|
10
|
+
constructor(nodeBefore, nodeMarker, attrName=null, attrValue=null) {
|
|
11
|
+
super(null, nodeMarker, attrName, attrValue);
|
|
12
|
+
this.eventName = attrName ? attrName.slice(2) : null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Handle attributes for event binding, such as:
|
|
17
|
+
* onclick=${(e, el) => this.doSomething(el, 'meow')}
|
|
18
|
+
* oninput=${[this.doSomething, 'meow']}
|
|
19
|
+
* onclick=${[this, 'doSomething', 'meow']}
|
|
20
|
+
*
|
|
21
|
+
* @param exprs {Expr[]} Only the first is used.*/
|
|
22
|
+
apply(exprs) {
|
|
23
|
+
//#IFDEV
|
|
24
|
+
assert(Array.isArray(exprs));
|
|
25
|
+
//#ENDIF
|
|
26
|
+
|
|
27
|
+
// Tested by Solariate.events.classicWithExpr
|
|
28
|
+
// We have expressions within a string attribute value that's not a Solarite event. E.g.
|
|
29
|
+
// <div onclick="alert(${1});"
|
|
30
|
+
if (this.attrValue?.length > 1) {
|
|
31
|
+
super.apply(exprs);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.applySingle(exprs[0]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param expr {Expr} */
|
|
40
|
+
applySingle(expr) {
|
|
41
|
+
// Expressions within a string attribute value that's not a Solarite event.
|
|
42
|
+
if (this.attrValue?.length > 1)
|
|
43
|
+
return super.apply([expr]);
|
|
44
|
+
|
|
45
|
+
// Don't bind events to component placeholders.
|
|
46
|
+
// PathToComponent will do the binding later when it instantiates the component.
|
|
47
|
+
if (this.isComponentAttrib && this.nodeMarker.tagName.endsWith('-SOLARITE-PLACEHOLDER'))
|
|
48
|
+
return;
|
|
49
|
+
|
|
50
|
+
let root = this.parentNg.rootNg.root
|
|
51
|
+
|
|
52
|
+
/*#IFDEV*/
|
|
53
|
+
assert(root?.nodeType === 1);
|
|
54
|
+
/*#ENDIF*/
|
|
55
|
+
|
|
56
|
+
let node = this.nodeMarker;
|
|
57
|
+
|
|
58
|
+
let eventName = this.eventName;
|
|
59
|
+
let func;
|
|
60
|
+
|
|
61
|
+
// Array form: oninput=${[this.doSomething, 'meow']}
|
|
62
|
+
// The whole array is passed to bindEvent so no args array has to be allocated here.
|
|
63
|
+
if (Array.isArray(expr) && typeof expr[0] === 'function')
|
|
64
|
+
func = expr[0];
|
|
65
|
+
else if (typeof expr === 'function') {
|
|
66
|
+
func = expr;
|
|
67
|
+
expr = null;
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
throw new Error(`Invalid event binding: <${node.tagName.toLowerCase()} ${this.attrName}=\${${JSON.stringify(expr)}}>`);
|
|
71
|
+
|
|
72
|
+
this.bindEvent(node, root, eventName, eventName, func, expr);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
65
77
|
}
|
package/src/PathToKey.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Path from "./Path.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Consumes the key=${expr} expression of a keyed template.
|
|
5
|
+
* Writes the value to its NodeGroup's key field and never touches the DOM.
|
|
6
|
+
* Created by Shell when it strips a key attribute; PathToNodes.applyKeyed()
|
|
7
|
+
* matches NodeGroups to new templates by this key. */
|
|
8
|
+
export default class PathToKey extends Path {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param exprs {Expr[]} Only the first is used. */
|
|
12
|
+
apply(exprs) {
|
|
13
|
+
this.parentNg.key = exprs[0];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
applySingle(expr) {
|
|
17
|
+
this.parentNg.key = expr;
|
|
18
|
+
}
|
|
19
|
+
}
|