@b9g/crank 0.4.4 → 0.5.0-beta.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/README.md +15 -50
- package/crank.cjs +24 -6
- package/crank.cjs.map +1 -1
- package/crank.d.ts +1 -3
- package/crank.js +24 -6
- package/crank.js.map +1 -1
- package/index.cjs +2 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/package.json +24 -16
- package/umd.js +24 -6
- package/umd.js.map +1 -1
- package/xm.cjs +431 -0
- package/xm.cjs.map +1 -0
- package/xm.d.ts +2 -0
- package/xm.js +428 -0
- package/xm.js.map +1 -0
package/crank.d.ts
CHANGED
|
@@ -166,9 +166,7 @@ export declare function isElement(value: any): value is Element;
|
|
|
166
166
|
* children prop according to any additional arguments passed to the function.
|
|
167
167
|
*/
|
|
168
168
|
export declare function createElement<TTag extends Tag>(tag: TTag, props?: TagProps<TTag> | null | undefined, ...children: Array<unknown>): Element<TTag>;
|
|
169
|
-
/**
|
|
170
|
-
* Clones a given element, shallowly copying the props object.
|
|
171
|
-
*/
|
|
169
|
+
/** Clones a given element, shallowly copying the props object. */
|
|
172
170
|
export declare function cloneElement<TTag extends Tag>(el: Element<TTag>): Element<TTag>;
|
|
173
171
|
/**
|
|
174
172
|
* A helper type which repesents all possible rendered values of an element.
|
package/crank.js
CHANGED
|
@@ -105,6 +105,7 @@ class Element {
|
|
|
105
105
|
this.static_ = static_;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
// See Element interface
|
|
108
109
|
Element.prototype.$$typeof = ElementSymbol;
|
|
109
110
|
function isElement(value) {
|
|
110
111
|
return value != null && value.$$typeof === ElementSymbol;
|
|
@@ -127,6 +128,7 @@ function createElement(tag, props, ...children) {
|
|
|
127
128
|
switch (name) {
|
|
128
129
|
case "crank-key":
|
|
129
130
|
case "c-key":
|
|
131
|
+
case "$key":
|
|
130
132
|
// We have to make sure we don’t assign null to the key because we
|
|
131
133
|
// don’t check for null keys in the diffing functions.
|
|
132
134
|
if (props[name] != null) {
|
|
@@ -135,12 +137,14 @@ function createElement(tag, props, ...children) {
|
|
|
135
137
|
break;
|
|
136
138
|
case "crank-ref":
|
|
137
139
|
case "c-ref":
|
|
140
|
+
case "$ref":
|
|
138
141
|
if (typeof props[name] === "function") {
|
|
139
142
|
ref = props[name];
|
|
140
143
|
}
|
|
141
144
|
break;
|
|
142
145
|
case "crank-static":
|
|
143
146
|
case "c-static":
|
|
147
|
+
case "$static":
|
|
144
148
|
static_ = !!props[name];
|
|
145
149
|
break;
|
|
146
150
|
default:
|
|
@@ -154,11 +158,25 @@ function createElement(tag, props, ...children) {
|
|
|
154
158
|
else if (children.length === 1) {
|
|
155
159
|
props1.children = children[0];
|
|
156
160
|
}
|
|
161
|
+
// string aliases for the special tags
|
|
162
|
+
// TODO: Does this logic belong here, or in the Element constructor
|
|
163
|
+
switch (tag) {
|
|
164
|
+
case "$FRAGMENT":
|
|
165
|
+
tag = Fragment;
|
|
166
|
+
break;
|
|
167
|
+
case "$PORTAL":
|
|
168
|
+
tag = Portal;
|
|
169
|
+
break;
|
|
170
|
+
case "$COPY":
|
|
171
|
+
tag = Copy;
|
|
172
|
+
break;
|
|
173
|
+
case "$RAW":
|
|
174
|
+
tag = Raw;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
157
177
|
return new Element(tag, props1, key, ref, static_);
|
|
158
178
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Clones a given element, shallowly copying the props object.
|
|
161
|
-
*/
|
|
179
|
+
/** Clones a given element, shallowly copying the props object. */
|
|
162
180
|
function cloneElement(el) {
|
|
163
181
|
if (!isElement(el)) {
|
|
164
182
|
throw new TypeError("Cannot clone non-element");
|
|
@@ -732,9 +750,9 @@ const IsDone = 1 << 4;
|
|
|
732
750
|
*
|
|
733
751
|
* NOTE: This is mainly used to prevent some false positives in component
|
|
734
752
|
* yields or returns undefined warnings. The reason we’re using this versus
|
|
735
|
-
* IsUnmounted is a very troubling
|
|
736
|
-
*
|
|
737
|
-
*
|
|
753
|
+
* IsUnmounted is a very troubling test (cascades sync generator parent and
|
|
754
|
+
* sync generator child) where synchronous code causes a stack overflow error
|
|
755
|
+
* in a non-deterministic way. Deeply disturbing stuff.
|
|
738
756
|
*/
|
|
739
757
|
const IsErrored = 1 << 5;
|
|
740
758
|
/**
|