@solidjs/web 2.0.0-beta.14 → 2.0.0-beta.16

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/dist/server.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createRenderEffect, createMemo, sharedConfig, createRoot, ssrHandleError, getOwner, runWithOwner, createComponent, omit, getNextChildId, createOwner } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, createRoot, ssrHandleError, getOwner, runWithOwner, createComponent, omit, getNextChildId, NotReadyError } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, ssrScope as scope, untrack } from 'solid-js';
3
3
  import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
4
4
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
5
5
 
@@ -59,9 +59,9 @@ const syncOptions = {
59
59
  sync: true
60
60
  };
61
61
  const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
62
- transparent: true,
63
62
  sync: true,
64
- ...options
63
+ ...options,
64
+ transparent: !options.scope
65
65
  } : transparentOptions);
66
66
  const memo = fn => createMemo(() => fn(), syncOptions);
67
67
 
@@ -93,9 +93,15 @@ function getLocalHeaderScript(id) {
93
93
  return getCrossReferenceHeader(id) + ";";
94
94
  }
95
95
 
96
+ function joinAssetPath(base, file) {
97
+ if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
98
+ if (typeof base !== "string" || !base) base = "/";
99
+ if (base[base.length - 1] !== "/") base += "/";
100
+ return base + (file[0] === "/" ? file.slice(1) : file);
101
+ }
96
102
  function resolveAssets(moduleUrl, manifest) {
97
103
  if (!manifest) return null;
98
- const base = manifest._base || "/";
104
+ const base = manifest._base;
99
105
  const entry = manifest[moduleUrl];
100
106
  if (!entry) return null;
101
107
  const css = [];
@@ -106,8 +112,8 @@ function resolveAssets(moduleUrl, manifest) {
106
112
  visited.add(key);
107
113
  const e = manifest[key];
108
114
  if (!e) return;
109
- js.push(base + e.file);
110
- if (e.css) for (let i = 0; i < e.css.length; i++) css.push(base + e.css[i]);
115
+ js.push(joinAssetPath(base, e.file));
116
+ if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
111
117
  if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
112
118
  };
113
119
  walk(moduleUrl);
@@ -496,38 +502,41 @@ function renderToStream(code, options = {}) {
496
502
  }, {
497
503
  id: renderId
498
504
  });
499
- function doShell() {
500
- if (shellCompleted) return;
501
- if (rootHoles) {
502
- const pending = [];
503
- for (const {
504
- id,
505
- fn
506
- } of rootHoles) {
507
- const marker = `<!--rh${id}-->`;
508
- const res = resolveSSRNode(fn);
509
- if (!res.h.length) {
510
- html = html.replace(marker, res.t[0]);
511
- } else {
512
- let out = res.t[0];
513
- for (let j = 0; j < res.h.length; j++) {
514
- const newId = nextHoleId++;
515
- pending.push({
516
- id: newId,
517
- fn: res.h[j]
518
- });
519
- out += `<!--rh${newId}-->` + res.t[j + 1];
520
- }
521
- html = html.replace(marker, out);
522
- for (const p of res.p) blockingPromises.add(p);
505
+ function resolveRootHoles() {
506
+ if (!rootHoles) return true;
507
+ const pending = [];
508
+ for (const {
509
+ id,
510
+ fn
511
+ } of rootHoles) {
512
+ const marker = `<!--rh${id}-->`;
513
+ const res = resolveSSRNode(fn);
514
+ if (!res.h.length) {
515
+ html = html.replace(marker, res.t[0]);
516
+ } else {
517
+ let out = res.t[0];
518
+ for (let j = 0; j < res.h.length; j++) {
519
+ const newId = nextHoleId++;
520
+ pending.push({
521
+ id: newId,
522
+ fn: res.h[j]
523
+ });
524
+ out += `<!--rh${newId}-->` + res.t[j + 1];
523
525
  }
526
+ html = html.replace(marker, out);
527
+ for (const p of res.p) blockingPromises.add(p);
524
528
  }
525
- if (pending.length) {
526
- rootHoles = pending;
527
- return;
528
- }
529
- rootHoles = null;
530
529
  }
530
+ if (pending.length) {
531
+ rootHoles = pending;
532
+ return false;
533
+ }
534
+ rootHoles = null;
535
+ return true;
536
+ }
537
+ function doShell() {
538
+ if (shellCompleted) return;
539
+ if (!resolveRootHoles()) return;
531
540
  sharedConfig.context = context;
532
541
  html = injectAssets(context.assets, html);
533
542
  headStyles = new Set();
@@ -559,7 +568,15 @@ function renderToStream(code, options = {}) {
559
568
  complete();
560
569
  };
561
570
  } else onCompleteAll = complete;
562
- queue(flushEnd);
571
+ function flush() {
572
+ allSettled(blockingPromises).then(() => {
573
+ setTimeout(() => {
574
+ if (!resolveRootHoles()) return flush();
575
+ queue(flushEnd);
576
+ });
577
+ });
578
+ }
579
+ flush();
563
580
  },
564
581
  pipe(w) {
565
582
  function flush() {
@@ -940,29 +957,6 @@ function tryJoinPlainSSRArray(nodes) {
940
957
  }
941
958
  return out;
942
959
  }
943
- function mergeProps(...sources) {
944
- const target = {};
945
- for (let i = 0; i < sources.length; i++) {
946
- let source = sources[i];
947
- if (typeof source === "function") source = source();
948
- if (source) {
949
- const descriptors = Object.getOwnPropertyDescriptors(source);
950
- for (const key in descriptors) {
951
- if (key in target) continue;
952
- Object.defineProperty(target, key, {
953
- enumerable: true,
954
- get() {
955
- for (let i = sources.length - 1; i >= 0; i--) {
956
- const v = (sources[i] || {})[key];
957
- if (v !== undefined) return v;
958
- }
959
- }
960
- });
961
- }
962
- }
963
- }
964
- return target;
965
- }
966
960
  function getHydrationKey() {
967
961
  const hydrate = sharedConfig.context;
968
962
  return hydrate && sharedConfig.getNextContextId();
@@ -1111,6 +1105,10 @@ function tryResolveString(node) {
1111
1105
  if (node.h && node.h.length > 0) return {
1112
1106
  merge: node
1113
1107
  };
1108
+ if (node.t === undefined) {
1109
+ console.warn(`Unrecognized value. Skipped inserting`, node);
1110
+ return "";
1111
+ }
1114
1112
  return Array.isArray(node.t) ? node.t[0] : node.t;
1115
1113
  }
1116
1114
  if (t === "function") {
@@ -1149,7 +1147,9 @@ function resolveSSRNode(node, result = {
1149
1147
  result.h.push(...node.h);
1150
1148
  result.p.push(...node.p);
1151
1149
  }
1152
- } else result.t[result.t.length - 1] += node.t;
1150
+ } else if (node.t !== undefined) {
1151
+ result.t[result.t.length - 1] += node.t;
1152
+ } else console.warn(`Unrecognized value. Skipped inserting`, node);
1153
1153
  } else if (t === "function") {
1154
1154
  try {
1155
1155
  resolveSSRNode(node(), result);
@@ -1186,15 +1186,38 @@ function dynamic(source) {
1186
1186
  const o = getOwner();
1187
1187
  if (o?.id != null) getNextChildId(o);
1188
1188
  return props => {
1189
- const memoOwner = createOwner();
1190
- return runWithOwner(memoOwner, () => {
1191
- const comp = source(),
1192
- t = typeof comp;
1193
- if (comp) {
1194
- if (t === "function") return comp(props);else if (t === "string") {
1195
- return ssrElement(comp, props, undefined, true);
1189
+ const comp = source();
1190
+ let p;
1191
+ let settled = false;
1192
+ let value;
1193
+ let error;
1194
+ if (comp && typeof comp.then === "function") {
1195
+ p = comp;
1196
+ p.then(v => {
1197
+ value = v;
1198
+ settled = true;
1199
+ }, err => {
1200
+ error = err;
1201
+ settled = true;
1202
+ });
1203
+ const ctx = sharedConfig.context;
1204
+ if (ctx?.async) ctx.block(p.then(() => {}, () => {}));
1205
+ }
1206
+ return createMemo(() => {
1207
+ let c = comp;
1208
+ if (p) {
1209
+ if (!settled) throw new NotReadyError(p);
1210
+ if (error) throw error;
1211
+ c = value;
1212
+ }
1213
+ if (c) {
1214
+ if (typeof c === "function") return c(props);
1215
+ if (typeof c === "string") {
1216
+ return ssrElement(c, props, undefined, true);
1196
1217
  }
1197
1218
  }
1219
+ }, {
1220
+ sync: true
1198
1221
  });
1199
1222
  };
1200
1223
  }
@@ -1206,4 +1229,4 @@ function Portal(props) {
1206
1229
  throw new Error("Portal is not supported on the server");
1207
1230
  }
1208
1231
 
1209
- export { Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as addEvent, applyRef, notSup as assign, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, notSup as getDelegatedRoot, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useAssets };
1232
+ export { Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as addEvent, applyRef, notSup as assign, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, notSup as getDelegatedRoot, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useAssets };
package/dist/web.cjs CHANGED
@@ -32,6 +32,7 @@ const DOMWithState = {
32
32
  };
33
33
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
34
34
  const $$SLOT = /*#__PURE__*/Symbol("slot");
35
+ const $$HOST = /*#__PURE__*/Symbol("host");
35
36
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
36
37
  const SVGElements = /*#__PURE__*/new Set([
37
38
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
@@ -59,9 +60,9 @@ const syncOptions = {
59
60
  sync: true
60
61
  };
61
62
  const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
62
- transparent: true,
63
63
  sync: true,
64
- ...options
64
+ ...options,
65
+ transparent: !options.scope
65
66
  } : transparentOptions);
66
67
  const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
67
68
 
@@ -329,20 +330,41 @@ function addEvent(node, name, handler, delegate) {
329
330
  }
330
331
  function style(node, value, prev) {
331
332
  if (!value) {
332
- if (prev) setAttribute(node, "style");
333
+ if (prev || node._$styles) {
334
+ setAttribute(node, "style");
335
+ node._$styles = undefined;
336
+ }
333
337
  return;
334
338
  }
335
339
  const nodeStyle = node.style;
336
- if (typeof value === "string") return nodeStyle.cssText = value;
337
- typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
338
- prev || (prev = {});
340
+ if (typeof value === "string") {
341
+ node._$styles = undefined;
342
+ return nodeStyle.cssText = value;
343
+ }
344
+ if (typeof prev === "string") {
345
+ nodeStyle.cssText = "";
346
+ prev = undefined;
347
+ }
348
+ let applied = node._$styles;
349
+ if (!applied) {
350
+ applied = node._$styles = prev ? {
351
+ ...prev
352
+ } : {};
353
+ }
339
354
  let v, s;
355
+ for (s in applied) {
356
+ if (value[s] == null) {
357
+ nodeStyle.removeProperty(s);
358
+ delete applied[s];
359
+ }
360
+ }
340
361
  for (s in value) {
341
362
  v = value[s];
342
- if (v !== prev[s]) nodeStyle.setProperty(s, v);
343
- delete prev[s];
363
+ if (v != null && v !== applied[s]) {
364
+ nodeStyle.setProperty(s, v);
365
+ applied[s] = v;
366
+ }
344
367
  }
345
- for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
346
368
  }
347
369
  function setStyleProperty(node, name, value) {
348
370
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
@@ -381,22 +403,36 @@ function ref(fn, element) {
381
403
  const resolved = solidJs.untrack(fn);
382
404
  solidJs.runWithOwner(null, () => applyRef(resolved, element));
383
405
  }
406
+ function scope(fn) {
407
+ fn.$s = true;
408
+ return fn;
409
+ }
410
+ const SCOPE_OPTIONS = {
411
+ scope: true
412
+ };
413
+ function stripTextSeparators(nodes) {
414
+ let j = 0;
415
+ for (let i = 0; i < nodes.length; i++) {
416
+ if (nodes[i].nodeType === 8 && nodes[i].nodeValue === "!$") nodes[i].remove();else nodes[j++] = nodes[i];
417
+ }
418
+ nodes.length = j;
419
+ return nodes;
420
+ }
384
421
  function insert(parent, accessor, marker, initial, options) {
385
422
  const multi = marker !== undefined;
423
+ const host = options && options.host;
386
424
  if (multi && !initial) initial = [];
387
425
  if (isHydrating(parent)) {
388
426
  if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
389
- if (Array.isArray(initial)) {
390
- let j = 0;
391
- for (let i = 0; i < initial.length; i++) {
392
- if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
393
- }
394
- initial.length = j;
395
- }
427
+ if (Array.isArray(initial)) stripTextSeparators(initial);
396
428
  }
397
429
  if (typeof accessor !== "function") {
398
430
  accessor = normalize(accessor, initial, multi, true);
399
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
431
+ if (typeof accessor !== "function") {
432
+ insertExpression(parent, accessor, initial, marker);
433
+ host && tagHost(accessor, host);
434
+ return;
435
+ }
400
436
  }
401
437
  if (multi && initial.length === 0) {
402
438
  const placeholder = document.createTextNode("");
@@ -404,12 +440,37 @@ function insert(parent, accessor, marker, initial, options) {
404
440
  initial = [placeholder];
405
441
  }
406
442
  let current = initial;
443
+ function reclaimSwappedRegion() {
444
+ if (!solidJs.sharedConfig.hydrating || !current || !parent.isConnected) return;
445
+ const first = Array.isArray(current) ? current[0] : current;
446
+ if (!first || !first.nodeType || first.isConnected) return;
447
+ let nodes;
448
+ if (marker) {
449
+ nodes = [];
450
+ let node = marker.previousSibling,
451
+ depth = 0;
452
+ while (node) {
453
+ if (node.nodeType === 8) {
454
+ const v = node.nodeValue;
455
+ if (v === "/") depth++;else if (v === "$") {
456
+ if (depth === 0) break;
457
+ depth--;
458
+ }
459
+ }
460
+ nodes.unshift(node);
461
+ node = node.previousSibling;
462
+ }
463
+ } else nodes = [...parent.childNodes];
464
+ current = stripTextSeparators(nodes);
465
+ }
407
466
  effect(prev => {
467
+ reclaimSwappedRegion();
408
468
  const value = normalize(accessor(), current, multi, true);
409
469
  if (typeof value !== "function") return value;
410
- effect(() => normalize(value, current, multi), inner => {
470
+ effect(() => (reclaimSwappedRegion(), normalize(value, current, multi)), inner => {
411
471
  insertExpression(parent, inner, current, marker);
412
472
  current = inner;
473
+ host && tagHost(current, host);
413
474
  }, prev !== undefined && !(options && options.schedule) ? {
414
475
  ...options,
415
476
  schedule: true
@@ -419,7 +480,12 @@ function insert(parent, accessor, marker, initial, options) {
419
480
  if (value === INNER_OWNED) return;
420
481
  insertExpression(parent, value, current, marker);
421
482
  current = value;
422
- }, options);
483
+ host && tagHost(current, host);
484
+ },
485
+ accessor.$s ? options ? {
486
+ ...options,
487
+ scope: true
488
+ } : SCOPE_OPTIONS : options);
423
489
  }
424
490
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
425
491
  const nodeName = node.nodeName;
@@ -448,6 +514,9 @@ function loadModuleAssets(mapping) {
448
514
  if (!hy.loading[moduleUrl]) {
449
515
  hy.loading[moduleUrl] = import(entryUrl).then(mod => {
450
516
  hy.modules[moduleUrl] = mod;
517
+ }, err => {
518
+ delete hy.loading[moduleUrl];
519
+ throw err;
451
520
  });
452
521
  }
453
522
  pending.push(hy.loading[moduleUrl]);
@@ -495,8 +564,11 @@ function hydrate$1(code, element, options = {}) {
495
564
  } finally {
496
565
  solidJs.sharedConfig.hydrating = false;
497
566
  }
498
- }, () => {
567
+ }, err => {
568
+ console.error("Hydration module preload failed, falling back to client render:", err);
499
569
  solidJs.sharedConfig.hydrating = false;
570
+ solidJs.sharedConfig.registry = undefined;
571
+ disposer = render$1(code, element, [...element.childNodes], options);
500
572
  });
501
573
  return () => disposer && disposer();
502
574
  }
@@ -566,17 +638,32 @@ function runHydrationEvents() {
566
638
  const [el, e] = events[0];
567
639
  if (!completed.has(el)) return;
568
640
  events.shift();
569
- let match;
641
+ let matchContainer, matchState, matchDistance, matches;
570
642
  for (const [container, state] of delegatedContainers) {
571
643
  if (!state.handlers.has(e.type)) continue;
572
644
  const entry = findOwner(e.target, state);
573
- if (entry && (!match || entry.distance < match.distance)) match = {
574
- container,
575
- state,
576
- distance: entry.distance
577
- };
645
+ if (!entry) continue;
646
+ if (matchContainer) {
647
+ if (!matches) matches = [{
648
+ container: matchContainer,
649
+ state: matchState,
650
+ distance: matchDistance
651
+ }];
652
+ matches.push({
653
+ container,
654
+ state,
655
+ distance: entry.distance
656
+ });
657
+ } else {
658
+ matchContainer = container;
659
+ matchState = state;
660
+ matchDistance = entry.distance;
661
+ }
578
662
  }
579
- if (match) eventHandler(e, match.container, match.state);
663
+ if (matches) {
664
+ matches.sort((a, b) => a.distance - b.distance);
665
+ for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
666
+ } else if (matchContainer) eventHandler(e, matchContainer, matchState);
580
667
  }
581
668
  if (solidJs.sharedConfig.done) {
582
669
  solidJs.sharedConfig.events = _$HY.events = null;
@@ -647,11 +734,16 @@ function eventHandler(e, container, state) {
647
734
  if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
648
735
  if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
649
736
  }
650
- if (e[$$EVENT_OWNER]) return;
737
+ const prev = e[$$EVENT_OWNER];
738
+ let resumeNode;
739
+ if (prev) {
740
+ if (prev === true || prev === container || !container.contains(prev)) return;
741
+ resumeNode = prev;
742
+ }
651
743
  const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
652
744
  if (state && !owner) return;
653
745
  e[$$EVENT_OWNER] = owner || true;
654
- let node = e.target;
746
+ let node = resumeNode || e.target;
655
747
  const key = `$$${e.type}`;
656
748
  const oriTarget = e.target;
657
749
  const boundary = owner || container || e.currentTarget;
@@ -681,7 +773,10 @@ function eventHandler(e, container, state) {
681
773
  return node || boundary || document;
682
774
  }
683
775
  });
684
- if (e.composedPath) {
776
+ if (resumeNode) {
777
+ if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
778
+ if (node && node !== boundary) walkUpTree();
779
+ } else if (e.composedPath) {
685
780
  const path = e.composedPath();
686
781
  if (path.length) {
687
782
  retarget(path[0]);
@@ -756,6 +851,17 @@ function normalize(value, current, multi, doNotUnwrap) {
756
851
  }
757
852
  return value;
758
853
  }
854
+ function tagHost(value, host) {
855
+ if (Array.isArray(value)) {
856
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
857
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
858
+ value[$$HOST] = host;
859
+ Object.defineProperty(value, "_$host", {
860
+ get: host,
861
+ configurable: true
862
+ });
863
+ }
864
+ }
759
865
  function appendNodes(parent, array, marker = null) {
760
866
  for (let i = 0, len = array.length; i < len; i++) {
761
867
  const n = array[i];
@@ -838,21 +944,33 @@ function Portal(props) {
838
944
  const treeMarker = document.createTextNode(""),
839
945
  startMarker = document.createTextNode(""),
840
946
  endMarker = document.createTextNode(""),
841
- mount = () => createElementProxy(props.mount || document.body, treeMarker),
947
+ mount = () => props.mount || document.body,
842
948
  content = solidJs.createMemo(() => [startMarker, props.children]);
843
- solidJs.createRenderEffect(() => [mount(), content()], ([m, c]) => {
949
+ solidJs.createRenderEffect(
950
+ () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
951
+ const m = solidJs.untrack(mount);
844
952
  m.appendChild(endMarker);
845
- insert(m, c, endMarker);
953
+ const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
954
+ insert(m, c, endMarker, undefined, {
955
+ host: () => treeMarker.parentNode
956
+ });
957
+ return d;
958
+ }));
846
959
  return () => {
960
+ dispose();
847
961
  let c = startMarker;
848
- while (c && c !== endMarker) {
962
+ while (c) {
849
963
  const n = c.nextSibling;
850
964
  m.removeChild(c);
965
+ if (c === endMarker) break;
851
966
  c = n;
852
967
  }
853
968
  };
969
+ }, {
970
+ schedule: true
854
971
  });
855
- solidJs.createEffect(mount, m => {
972
+ solidJs.createEffect(mount, () => {
973
+ const m = solidJs.untrack(mount);
856
974
  const ownerRoot = getDelegatedRoot(treeMarker);
857
975
  if (!ownerRoot || ownerRoot.contains(m)) return;
858
976
  registerDelegatedContainer(m, ownerRoot);
@@ -887,23 +1005,6 @@ function createElement(tagName, is = undefined) {
887
1005
  is
888
1006
  });
889
1007
  }
890
- function createElementProxy(el, marker) {
891
- return new Proxy(el, {
892
- get(target, prop) {
893
- if (prop === "appendChild" || prop === "insertBefore") {
894
- return (...args) => {
895
- Object.defineProperty(args[0], "_$host", {
896
- get: () => marker.parentNode,
897
- configurable: true
898
- });
899
- target[prop](...args);
900
- };
901
- }
902
- const value = Reflect.get(target, prop);
903
- return typeof value === "function" ? value.bind(target) : value;
904
- }
905
- });
906
- }
907
1008
 
908
1009
  Object.defineProperty(exports, "Errored", {
909
1010
  enumerable: true,
@@ -1005,6 +1106,7 @@ exports.renderToString = renderToString;
1005
1106
  exports.renderToStringAsync = renderToStringAsync;
1006
1107
  exports.resolveSSRNode = resolveSSRNode;
1007
1108
  exports.runHydrationEvents = runHydrationEvents;
1109
+ exports.scope = scope;
1008
1110
  exports.setAttribute = setAttribute;
1009
1111
  exports.setAttributeNS = setAttributeNS;
1010
1112
  exports.setProperty = setProperty;