mono-jsx 0.9.4 → 0.9.5
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/dom/jsx-runtime.mjs +17 -18
- package/jsx-runtime.mjs +1 -1
- package/package.json +1 -1
package/dom/jsx-runtime.mjs
CHANGED
|
@@ -117,18 +117,18 @@ var Ref = class {
|
|
|
117
117
|
};
|
|
118
118
|
var InsertMark = class {
|
|
119
119
|
#root;
|
|
120
|
-
#
|
|
121
|
-
constructor(root) {
|
|
120
|
+
#anchor;
|
|
121
|
+
constructor(root, signal) {
|
|
122
|
+
const anchor = createTextNode();
|
|
123
|
+
root.appendChild(anchor);
|
|
124
|
+
onAbort(signal, () => anchor.remove());
|
|
122
125
|
this.#root = root;
|
|
123
|
-
this.#
|
|
126
|
+
this.#anchor = anchor;
|
|
124
127
|
}
|
|
125
128
|
insert(...nodes) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (argsN > 1) tmp = createTextNode();
|
|
130
|
-
this.#root.insertBefore(tmp ?? nodes[0], this.#root.childNodes[this.#index]);
|
|
131
|
-
tmp?.replaceWith(...nodes);
|
|
129
|
+
const parent = this.#anchor.parentElement ?? this.#root;
|
|
130
|
+
for (const node of nodes) {
|
|
131
|
+
parent.insertBefore(node, this.#anchor);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
insertHTML(html2) {
|
|
@@ -310,7 +310,7 @@ var render = (scope, child, root, abortSignal) => {
|
|
|
310
310
|
if (child !== null) {
|
|
311
311
|
if (child instanceof ReactiveList) {
|
|
312
312
|
let { reactive, callback } = child;
|
|
313
|
-
let insertMark = new InsertMark(root);
|
|
313
|
+
let insertMark = new InsertMark(root, abortSignal);
|
|
314
314
|
let list = /* @__PURE__ */ new Map();
|
|
315
315
|
let cleanup = () => {
|
|
316
316
|
list.forEach((items) => items.forEach(([ac]) => ac.abort()));
|
|
@@ -360,17 +360,16 @@ var render = (scope, child, root, abortSignal) => {
|
|
|
360
360
|
switch (tag) {
|
|
361
361
|
// fragment element
|
|
362
362
|
case $fragment: {
|
|
363
|
-
const { children
|
|
364
|
-
const rootEl = rootProp instanceof HTMLElement ? rootProp : root;
|
|
363
|
+
const { children } = props;
|
|
365
364
|
if (children !== void 0) {
|
|
366
|
-
renderChildren(scope, children,
|
|
365
|
+
renderChildren(scope, children, root, abortSignal);
|
|
367
366
|
}
|
|
368
367
|
break;
|
|
369
368
|
}
|
|
370
369
|
// XSS!
|
|
371
370
|
case $html: {
|
|
372
371
|
const { innerHTML } = props;
|
|
373
|
-
const mark = new InsertMark(root);
|
|
372
|
+
const mark = new InsertMark(root, abortSignal);
|
|
374
373
|
if (innerHTML instanceof Reactive) {
|
|
375
374
|
let cleanup;
|
|
376
375
|
innerHTML.reactive((html2) => {
|
|
@@ -397,13 +396,13 @@ var render = (scope, child, root, abortSignal) => {
|
|
|
397
396
|
let { when = true, children } = props;
|
|
398
397
|
if (children !== void 0) {
|
|
399
398
|
if (when instanceof Reactive) {
|
|
400
|
-
let mark = new InsertMark(root);
|
|
399
|
+
let mark = new InsertMark(root, abortSignal);
|
|
401
400
|
let ac;
|
|
402
401
|
when.reactive((value) => {
|
|
403
402
|
ac?.abort();
|
|
404
403
|
if (tag === "show" ? value : !value) {
|
|
405
404
|
ac = new AbortController();
|
|
406
|
-
mark.insert(renderToFragment(scope, children, ac.signal));
|
|
405
|
+
mark.insert(...renderToFragment(scope, children, ac.signal).childNodes);
|
|
407
406
|
}
|
|
408
407
|
}, abortSignal);
|
|
409
408
|
onAbort(abortSignal, () => ac?.abort());
|
|
@@ -421,14 +420,14 @@ var render = (scope, child, root, abortSignal) => {
|
|
|
421
420
|
const { value: valueProp, children } = props;
|
|
422
421
|
if (children !== void 0) {
|
|
423
422
|
if (valueProp instanceof Reactive) {
|
|
424
|
-
let mark = new InsertMark(root);
|
|
423
|
+
let mark = new InsertMark(root, abortSignal);
|
|
425
424
|
let ac;
|
|
426
425
|
valueProp.reactive((value) => {
|
|
427
426
|
const slots = children.filter((v) => isVNode(v) && v[1].slot === String(value));
|
|
428
427
|
ac?.abort();
|
|
429
428
|
if (slots.length > 0) {
|
|
430
429
|
ac = new AbortController();
|
|
431
|
-
mark.insert(renderToFragment(scope, slots, ac.signal));
|
|
430
|
+
mark.insert(...renderToFragment(scope, slots, ac.signal).childNodes);
|
|
432
431
|
}
|
|
433
432
|
}, abortSignal);
|
|
434
433
|
onAbort(abortSignal, () => ac?.abort());
|
package/jsx-runtime.mjs
CHANGED
|
@@ -176,7 +176,7 @@ var $vnode = /* @__PURE__ */ Symbol.for("jsx.vnode");
|
|
|
176
176
|
var $setup = /* @__PURE__ */ Symbol.for("mono.setup");
|
|
177
177
|
|
|
178
178
|
// version.ts
|
|
179
|
-
var VERSION = "0.9.
|
|
179
|
+
var VERSION = "0.9.5";
|
|
180
180
|
|
|
181
181
|
// render.ts
|
|
182
182
|
var FunctionIdGenerator = class extends Map {
|