dom-expressions 0.31.0 → 0.31.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/package.json +3 -3
- package/src/client.js +2 -2
- package/src/server.js +6 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dom-expressions",
|
|
3
3
|
"description": "A Fine-Grained Runtime for Performant DOM Rendering",
|
|
4
|
-
"version": "0.31.
|
|
4
|
+
"version": "0.31.4",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"devalue": "^2.0.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"babel-plugin-jsx-dom-expressions": "^0.31.
|
|
23
|
+
"babel-plugin-jsx-dom-expressions": "^0.31.4"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "411215d16c3bf06ced1b55ab76fc85108d053f98"
|
|
26
26
|
}
|
package/src/client.js
CHANGED
|
@@ -383,13 +383,13 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
383
383
|
}
|
|
384
384
|
current = array;
|
|
385
385
|
} else if (value instanceof Node) {
|
|
386
|
-
if (sharedConfig.context) return current = value.parentNode ? value : current;
|
|
386
|
+
if (sharedConfig.context) return (current = value.parentNode ? value : current);
|
|
387
387
|
if (Array.isArray(current)) {
|
|
388
388
|
if (multi) return (current = cleanChildren(parent, current, marker, value));
|
|
389
389
|
cleanChildren(parent, current, null, value);
|
|
390
390
|
} else if (current == null || current === "" || !parent.firstChild) {
|
|
391
391
|
parent.appendChild(value);
|
|
392
|
-
} else parent.replaceChild(value, parent.firstChild);
|
|
392
|
+
} else parent.replaceChild(value, multi ? current : parent.firstChild);
|
|
393
393
|
current = value;
|
|
394
394
|
} else if ("_DX_DEV_") console.warn(`Unrecognized value. Skipped inserting`, value);
|
|
395
395
|
|
package/src/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { sharedConfig } from "rxcore";
|
|
|
3
3
|
import devalue from "devalue";
|
|
4
4
|
export { createComponent } from "rxcore";
|
|
5
5
|
|
|
6
|
-
const REPLACE_SCRIPT = `function $df(e,y,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e,y)}`;
|
|
6
|
+
const REPLACE_SCRIPT = `function $df(e,y,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e,y||null)}`;
|
|
7
7
|
const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
|
|
8
8
|
|
|
9
9
|
export function renderToString(code, options = {}) {
|
|
@@ -37,7 +37,7 @@ export function renderToStringAsync(code, options = {}) {
|
|
|
37
37
|
nonce,
|
|
38
38
|
writeResource(id, p, error) {
|
|
39
39
|
if (error) return (scripts += `_$HY.set("${id}", ${serializeError(p)});`);
|
|
40
|
-
if (typeof p !== "object" || !("then" in p))
|
|
40
|
+
if (!p || typeof p !== "object" || !("then" in p))
|
|
41
41
|
return (scripts += `_$HY.set("${id}", ${devalue(p)});`);
|
|
42
42
|
p.then(d => (scripts += `_$HY.set("${id}", ${devalue(d)});`)).catch(
|
|
43
43
|
() => (scripts += `_$HY.set("${id}", {});`)
|
|
@@ -62,7 +62,7 @@ export function renderToStringAsync(code, options = {}) {
|
|
|
62
62
|
cache[key] = value;
|
|
63
63
|
registry.delete(key);
|
|
64
64
|
if (error) scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;
|
|
65
|
-
else scripts += `_$HY.set("${key}",
|
|
65
|
+
else scripts += `_$HY.set("${key}", null);`;
|
|
66
66
|
if (!registry.size)
|
|
67
67
|
Promise.resolve().then(() => {
|
|
68
68
|
let source = resolveSSRNode(rendered);
|
|
@@ -130,7 +130,7 @@ export function renderToStream(code, options = {}) {
|
|
|
130
130
|
scheduled = true;
|
|
131
131
|
}
|
|
132
132
|
if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
|
|
133
|
-
if (typeof p !== "object" || !("then" in p))
|
|
133
|
+
if (!p || typeof p !== "object" || !("then" in p))
|
|
134
134
|
return tasks.push(`_$HY.set("${id}", ${devalue(p)})`);
|
|
135
135
|
tasks.push(`_$HY.init("${id}")`);
|
|
136
136
|
p.then(d => {
|
|
@@ -428,6 +428,7 @@ function waitForFragments(registry, key) {
|
|
|
428
428
|
return false;
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
+
/* istanbul ignore next */
|
|
431
432
|
/**
|
|
432
433
|
* @deprecated Replaced by renderToStream
|
|
433
434
|
*/
|
|
@@ -445,6 +446,7 @@ export function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
445
446
|
if (!options.onReady) stream.pipe(writable);
|
|
446
447
|
}
|
|
447
448
|
|
|
449
|
+
/* istanbul ignore next */
|
|
448
450
|
/**
|
|
449
451
|
* @deprecated Replaced by renderToStream
|
|
450
452
|
*/
|