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

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/dev.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",
@@ -388,6 +389,7 @@ function ref(fn, element) {
388
389
  }
389
390
  function insert(parent, accessor, marker, initial, options) {
390
391
  const multi = marker !== undefined;
392
+ const host = options && options.host;
391
393
  if (multi && !initial) initial = [];
392
394
  if (isHydrating(parent)) {
393
395
  if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
@@ -401,7 +403,11 @@ function insert(parent, accessor, marker, initial, options) {
401
403
  }
402
404
  if (typeof accessor !== "function") {
403
405
  accessor = normalize(accessor, initial, multi, true);
404
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
406
+ if (typeof accessor !== "function") {
407
+ insertExpression(parent, accessor, initial, marker);
408
+ host && tagHost(accessor, host);
409
+ return;
410
+ }
405
411
  }
406
412
  if (multi && initial.length === 0) {
407
413
  const placeholder = document.createTextNode("");
@@ -415,6 +421,7 @@ function insert(parent, accessor, marker, initial, options) {
415
421
  effect(() => normalize(value, current, multi), inner => {
416
422
  insertExpression(parent, inner, current, marker);
417
423
  current = inner;
424
+ host && tagHost(current, host);
418
425
  }, prev !== undefined && !(options && options.schedule) ? {
419
426
  ...options,
420
427
  schedule: true
@@ -424,6 +431,7 @@ function insert(parent, accessor, marker, initial, options) {
424
431
  if (value === INNER_OWNED) return;
425
432
  insertExpression(parent, value, current, marker);
426
433
  current = value;
434
+ host && tagHost(current, host);
427
435
  }, options);
428
436
  }
429
437
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
@@ -813,6 +821,17 @@ function normalize(value, current, multi, doNotUnwrap) {
813
821
  }
814
822
  return value;
815
823
  }
824
+ function tagHost(value, host) {
825
+ if (Array.isArray(value)) {
826
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
827
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
828
+ value[$$HOST] = host;
829
+ Object.defineProperty(value, "_$host", {
830
+ get: host,
831
+ configurable: true
832
+ });
833
+ }
834
+ }
816
835
  function appendNodes(parent, array, marker = null) {
817
836
  for (let i = 0, len = array.length; i < len; i++) {
818
837
  const n = array[i];
@@ -897,12 +916,20 @@ function Portal(props) {
897
916
  const treeMarker = document.createTextNode(""),
898
917
  startMarker = document.createTextNode(""),
899
918
  endMarker = document.createTextNode(""),
900
- mount = () => createElementProxy(props.mount || document.body, treeMarker),
919
+ mount = () => props.mount || document.body,
901
920
  content = solidJs.createMemo(() => [startMarker, props.children]);
902
- solidJs.createRenderEffect(() => [mount(), content()], ([m, c]) => {
921
+ solidJs.createRenderEffect(
922
+ () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
923
+ const m = solidJs.untrack(mount);
903
924
  m.appendChild(endMarker);
904
- insert(m, c, endMarker);
925
+ const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
926
+ insert(m, c, endMarker, undefined, {
927
+ host: () => treeMarker.parentNode
928
+ });
929
+ return d;
930
+ }));
905
931
  return () => {
932
+ dispose();
906
933
  let c = startMarker;
907
934
  while (c && c !== endMarker) {
908
935
  const n = c.nextSibling;
@@ -910,8 +937,11 @@ function Portal(props) {
910
937
  c = n;
911
938
  }
912
939
  };
940
+ }, {
941
+ schedule: true
913
942
  });
914
- solidJs.createEffect(mount, m => {
943
+ solidJs.createEffect(mount, () => {
944
+ const m = solidJs.untrack(mount);
915
945
  const ownerRoot = getDelegatedRoot(treeMarker);
916
946
  if (!ownerRoot || ownerRoot.contains(m)) return;
917
947
  registerDelegatedContainer(m, ownerRoot);
@@ -949,23 +979,6 @@ function createElement(tagName, is = undefined) {
949
979
  is
950
980
  });
951
981
  }
952
- function createElementProxy(el, marker) {
953
- return new Proxy(el, {
954
- get(target, prop) {
955
- if (prop === "appendChild" || prop === "insertBefore") {
956
- return (...args) => {
957
- Object.defineProperty(args[0], "_$host", {
958
- get: () => marker.parentNode,
959
- configurable: true
960
- });
961
- target[prop](...args);
962
- };
963
- }
964
- const value = Reflect.get(target, prop);
965
- return typeof value === "function" ? value.bind(target) : value;
966
- }
967
- });
968
- }
969
982
 
970
983
  Object.defineProperty(exports, "Errored", {
971
984
  enumerable: true,
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createEffect, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, getOwner, createEffect, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
3
3
 
4
4
  const DOMWithState = {
@@ -31,6 +31,7 @@ const DOMWithState = {
31
31
  };
32
32
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
33
33
  const $$SLOT = /*#__PURE__*/Symbol("slot");
34
+ const $$HOST = /*#__PURE__*/Symbol("host");
34
35
  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"]);
35
36
  const SVGElements = /*#__PURE__*/new Set([
36
37
  "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",
@@ -387,6 +388,7 @@ function ref(fn, element) {
387
388
  }
388
389
  function insert(parent, accessor, marker, initial, options) {
389
390
  const multi = marker !== undefined;
391
+ const host = options && options.host;
390
392
  if (multi && !initial) initial = [];
391
393
  if (isHydrating(parent)) {
392
394
  if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
@@ -400,7 +402,11 @@ function insert(parent, accessor, marker, initial, options) {
400
402
  }
401
403
  if (typeof accessor !== "function") {
402
404
  accessor = normalize(accessor, initial, multi, true);
403
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
405
+ if (typeof accessor !== "function") {
406
+ insertExpression(parent, accessor, initial, marker);
407
+ host && tagHost(accessor, host);
408
+ return;
409
+ }
404
410
  }
405
411
  if (multi && initial.length === 0) {
406
412
  const placeholder = document.createTextNode("");
@@ -414,6 +420,7 @@ function insert(parent, accessor, marker, initial, options) {
414
420
  effect(() => normalize(value, current, multi), inner => {
415
421
  insertExpression(parent, inner, current, marker);
416
422
  current = inner;
423
+ host && tagHost(current, host);
417
424
  }, prev !== undefined && !(options && options.schedule) ? {
418
425
  ...options,
419
426
  schedule: true
@@ -423,6 +430,7 @@ function insert(parent, accessor, marker, initial, options) {
423
430
  if (value === INNER_OWNED) return;
424
431
  insertExpression(parent, value, current, marker);
425
432
  current = value;
433
+ host && tagHost(current, host);
426
434
  }, options);
427
435
  }
428
436
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
@@ -812,6 +820,17 @@ function normalize(value, current, multi, doNotUnwrap) {
812
820
  }
813
821
  return value;
814
822
  }
823
+ function tagHost(value, host) {
824
+ if (Array.isArray(value)) {
825
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
826
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
827
+ value[$$HOST] = host;
828
+ Object.defineProperty(value, "_$host", {
829
+ get: host,
830
+ configurable: true
831
+ });
832
+ }
833
+ }
815
834
  function appendNodes(parent, array, marker = null) {
816
835
  for (let i = 0, len = array.length; i < len; i++) {
817
836
  const n = array[i];
@@ -896,12 +915,20 @@ function Portal(props) {
896
915
  const treeMarker = document.createTextNode(""),
897
916
  startMarker = document.createTextNode(""),
898
917
  endMarker = document.createTextNode(""),
899
- mount = () => createElementProxy(props.mount || document.body, treeMarker),
918
+ mount = () => props.mount || document.body,
900
919
  content = createMemo(() => [startMarker, props.children]);
901
- createRenderEffect(() => [mount(), content()], ([m, c]) => {
920
+ createRenderEffect(
921
+ () => [mount(), content(), getOwner()], ([, c, owner]) => {
922
+ const m = untrack(mount);
902
923
  m.appendChild(endMarker);
903
- insert(m, c, endMarker);
924
+ const dispose = runWithOwner(owner, () => createRoot(d => {
925
+ insert(m, c, endMarker, undefined, {
926
+ host: () => treeMarker.parentNode
927
+ });
928
+ return d;
929
+ }));
904
930
  return () => {
931
+ dispose();
905
932
  let c = startMarker;
906
933
  while (c && c !== endMarker) {
907
934
  const n = c.nextSibling;
@@ -909,8 +936,11 @@ function Portal(props) {
909
936
  c = n;
910
937
  }
911
938
  };
939
+ }, {
940
+ schedule: true
912
941
  });
913
- createEffect(mount, m => {
942
+ createEffect(mount, () => {
943
+ const m = untrack(mount);
914
944
  const ownerRoot = getDelegatedRoot(treeMarker);
915
945
  if (!ownerRoot || ownerRoot.contains(m)) return;
916
946
  registerDelegatedContainer(m, ownerRoot);
@@ -948,22 +978,5 @@ function createElement(tagName, is = undefined) {
948
978
  is
949
979
  });
950
980
  }
951
- function createElementProxy(el, marker) {
952
- return new Proxy(el, {
953
- get(target, prop) {
954
- if (prop === "appendChild" || prop === "insertBefore") {
955
- return (...args) => {
956
- Object.defineProperty(args[0], "_$host", {
957
- get: () => marker.parentNode,
958
- configurable: true
959
- });
960
- target[prop](...args);
961
- };
962
- }
963
- const value = Reflect.get(target, prop);
964
- return typeof value === "function" ? value.bind(target) : value;
965
- }
966
- });
967
- }
968
981
 
969
982
  export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEvent, applyRef, assign, className, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, registerDelegatedContainer, registerDelegatedRoot, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as 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",
@@ -383,6 +384,7 @@ function ref(fn, element) {
383
384
  }
384
385
  function insert(parent, accessor, marker, initial, options) {
385
386
  const multi = marker !== undefined;
387
+ const host = options && options.host;
386
388
  if (multi && !initial) initial = [];
387
389
  if (isHydrating(parent)) {
388
390
  if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
@@ -396,7 +398,11 @@ function insert(parent, accessor, marker, initial, options) {
396
398
  }
397
399
  if (typeof accessor !== "function") {
398
400
  accessor = normalize(accessor, initial, multi, true);
399
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
401
+ if (typeof accessor !== "function") {
402
+ insertExpression(parent, accessor, initial, marker);
403
+ host && tagHost(accessor, host);
404
+ return;
405
+ }
400
406
  }
401
407
  if (multi && initial.length === 0) {
402
408
  const placeholder = document.createTextNode("");
@@ -410,6 +416,7 @@ function insert(parent, accessor, marker, initial, options) {
410
416
  effect(() => normalize(value, current, multi), inner => {
411
417
  insertExpression(parent, inner, current, marker);
412
418
  current = inner;
419
+ host && tagHost(current, host);
413
420
  }, prev !== undefined && !(options && options.schedule) ? {
414
421
  ...options,
415
422
  schedule: true
@@ -419,6 +426,7 @@ function insert(parent, accessor, marker, initial, options) {
419
426
  if (value === INNER_OWNED) return;
420
427
  insertExpression(parent, value, current, marker);
421
428
  current = value;
429
+ host && tagHost(current, host);
422
430
  }, options);
423
431
  }
424
432
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
@@ -756,6 +764,17 @@ function normalize(value, current, multi, doNotUnwrap) {
756
764
  }
757
765
  return value;
758
766
  }
767
+ function tagHost(value, host) {
768
+ if (Array.isArray(value)) {
769
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
770
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
771
+ value[$$HOST] = host;
772
+ Object.defineProperty(value, "_$host", {
773
+ get: host,
774
+ configurable: true
775
+ });
776
+ }
777
+ }
759
778
  function appendNodes(parent, array, marker = null) {
760
779
  for (let i = 0, len = array.length; i < len; i++) {
761
780
  const n = array[i];
@@ -838,12 +857,20 @@ function Portal(props) {
838
857
  const treeMarker = document.createTextNode(""),
839
858
  startMarker = document.createTextNode(""),
840
859
  endMarker = document.createTextNode(""),
841
- mount = () => createElementProxy(props.mount || document.body, treeMarker),
860
+ mount = () => props.mount || document.body,
842
861
  content = solidJs.createMemo(() => [startMarker, props.children]);
843
- solidJs.createRenderEffect(() => [mount(), content()], ([m, c]) => {
862
+ solidJs.createRenderEffect(
863
+ () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
864
+ const m = solidJs.untrack(mount);
844
865
  m.appendChild(endMarker);
845
- insert(m, c, endMarker);
866
+ const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
867
+ insert(m, c, endMarker, undefined, {
868
+ host: () => treeMarker.parentNode
869
+ });
870
+ return d;
871
+ }));
846
872
  return () => {
873
+ dispose();
847
874
  let c = startMarker;
848
875
  while (c && c !== endMarker) {
849
876
  const n = c.nextSibling;
@@ -851,8 +878,11 @@ function Portal(props) {
851
878
  c = n;
852
879
  }
853
880
  };
881
+ }, {
882
+ schedule: true
854
883
  });
855
- solidJs.createEffect(mount, m => {
884
+ solidJs.createEffect(mount, () => {
885
+ const m = solidJs.untrack(mount);
856
886
  const ownerRoot = getDelegatedRoot(treeMarker);
857
887
  if (!ownerRoot || ownerRoot.contains(m)) return;
858
888
  registerDelegatedContainer(m, ownerRoot);
@@ -887,23 +917,6 @@ function createElement(tagName, is = undefined) {
887
917
  is
888
918
  });
889
919
  }
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
920
 
908
921
  Object.defineProperty(exports, "Errored", {
909
922
  enumerable: true,
package/dist/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createEffect, enableHydration, flush } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, getOwner, createEffect, enableHydration, flush } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
3
3
 
4
4
  const DOMWithState = {
@@ -31,6 +31,7 @@ const DOMWithState = {
31
31
  };
32
32
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
33
33
  const $$SLOT = /*#__PURE__*/Symbol("slot");
34
+ const $$HOST = /*#__PURE__*/Symbol("host");
34
35
  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"]);
35
36
  const SVGElements = /*#__PURE__*/new Set([
36
37
  "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",
@@ -382,6 +383,7 @@ function ref(fn, element) {
382
383
  }
383
384
  function insert(parent, accessor, marker, initial, options) {
384
385
  const multi = marker !== undefined;
386
+ const host = options && options.host;
385
387
  if (multi && !initial) initial = [];
386
388
  if (isHydrating(parent)) {
387
389
  if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
@@ -395,7 +397,11 @@ function insert(parent, accessor, marker, initial, options) {
395
397
  }
396
398
  if (typeof accessor !== "function") {
397
399
  accessor = normalize(accessor, initial, multi, true);
398
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
400
+ if (typeof accessor !== "function") {
401
+ insertExpression(parent, accessor, initial, marker);
402
+ host && tagHost(accessor, host);
403
+ return;
404
+ }
399
405
  }
400
406
  if (multi && initial.length === 0) {
401
407
  const placeholder = document.createTextNode("");
@@ -409,6 +415,7 @@ function insert(parent, accessor, marker, initial, options) {
409
415
  effect(() => normalize(value, current, multi), inner => {
410
416
  insertExpression(parent, inner, current, marker);
411
417
  current = inner;
418
+ host && tagHost(current, host);
412
419
  }, prev !== undefined && !(options && options.schedule) ? {
413
420
  ...options,
414
421
  schedule: true
@@ -418,6 +425,7 @@ function insert(parent, accessor, marker, initial, options) {
418
425
  if (value === INNER_OWNED) return;
419
426
  insertExpression(parent, value, current, marker);
420
427
  current = value;
428
+ host && tagHost(current, host);
421
429
  }, options);
422
430
  }
423
431
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
@@ -755,6 +763,17 @@ function normalize(value, current, multi, doNotUnwrap) {
755
763
  }
756
764
  return value;
757
765
  }
766
+ function tagHost(value, host) {
767
+ if (Array.isArray(value)) {
768
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
769
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
770
+ value[$$HOST] = host;
771
+ Object.defineProperty(value, "_$host", {
772
+ get: host,
773
+ configurable: true
774
+ });
775
+ }
776
+ }
758
777
  function appendNodes(parent, array, marker = null) {
759
778
  for (let i = 0, len = array.length; i < len; i++) {
760
779
  const n = array[i];
@@ -837,12 +856,20 @@ function Portal(props) {
837
856
  const treeMarker = document.createTextNode(""),
838
857
  startMarker = document.createTextNode(""),
839
858
  endMarker = document.createTextNode(""),
840
- mount = () => createElementProxy(props.mount || document.body, treeMarker),
859
+ mount = () => props.mount || document.body,
841
860
  content = createMemo(() => [startMarker, props.children]);
842
- createRenderEffect(() => [mount(), content()], ([m, c]) => {
861
+ createRenderEffect(
862
+ () => [mount(), content(), getOwner()], ([, c, owner]) => {
863
+ const m = untrack(mount);
843
864
  m.appendChild(endMarker);
844
- insert(m, c, endMarker);
865
+ const dispose = runWithOwner(owner, () => createRoot(d => {
866
+ insert(m, c, endMarker, undefined, {
867
+ host: () => treeMarker.parentNode
868
+ });
869
+ return d;
870
+ }));
845
871
  return () => {
872
+ dispose();
846
873
  let c = startMarker;
847
874
  while (c && c !== endMarker) {
848
875
  const n = c.nextSibling;
@@ -850,8 +877,11 @@ function Portal(props) {
850
877
  c = n;
851
878
  }
852
879
  };
880
+ }, {
881
+ schedule: true
853
882
  });
854
- createEffect(mount, m => {
883
+ createEffect(mount, () => {
884
+ const m = untrack(mount);
855
885
  const ownerRoot = getDelegatedRoot(treeMarker);
856
886
  if (!ownerRoot || ownerRoot.contains(m)) return;
857
887
  registerDelegatedContainer(m, ownerRoot);
@@ -886,22 +916,5 @@ function createElement(tagName, is = undefined) {
886
916
  is
887
917
  });
888
918
  }
889
- function createElementProxy(el, marker) {
890
- return new Proxy(el, {
891
- get(target, prop) {
892
- if (prop === "appendChild" || prop === "insertBefore") {
893
- return (...args) => {
894
- Object.defineProperty(args[0], "_$host", {
895
- get: () => marker.parentNode,
896
- configurable: true
897
- });
898
- target[prop](...args);
899
- };
900
- }
901
- const value = Reflect.get(target, prop);
902
- return typeof value === "function" ? value.bind(target) : value;
903
- }
904
- });
905
- }
906
919
 
907
920
  export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEvent, applyRef, assign, className, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, registerDelegatedContainer, registerDelegatedRoot, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/web",
3
3
  "description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
4
- "version": "2.0.0-beta.14",
4
+ "version": "2.0.0-beta.15",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -137,10 +137,10 @@
137
137
  "seroval-plugins": "^1.1.0"
138
138
  },
139
139
  "peerDependencies": {
140
- "solid-js": "^2.0.0-beta.14"
140
+ "solid-js": "^2.0.0-beta.15"
141
141
  },
142
142
  "devDependencies": {
143
- "solid-js": "2.0.0-beta.14"
143
+ "solid-js": "2.0.0-beta.15"
144
144
  },
145
145
  "scripts": {
146
146
  "build": "npm-run-all -nl build:clean types:copy-jsx build:js",
package/types/client.d.ts CHANGED
@@ -30,7 +30,17 @@ export function insert<T>(
30
30
  parent: MountableElement,
31
31
  accessor: (() => T) | T,
32
32
  marker?: Node | null,
33
- init?: JSX.Element
33
+ init?: JSX.Element,
34
+ options?: {
35
+ /**
36
+ * Live accessor for the slot's logical host in the source tree (portals).
37
+ * Each top-level node the slot manages is tagged with a `_$host` getter
38
+ * backed by this accessor so delegated events retarget correctly.
39
+ */
40
+ host?: () => Node | null;
41
+ /** Defer the insert effect to the queue instead of running it inline. */
42
+ schedule?: boolean;
43
+ }
34
44
  ): JSX.Element;
35
45
  export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
36
46
  export function delegateEvents(eventNames: string[]): void;
package/types/jsx.d.ts CHANGED
@@ -226,8 +226,12 @@ export namespace JSX {
226
226
 
227
227
  export type ClassValue =
228
228
  | string
229
+ | number
230
+ | boolean
231
+ | null
232
+ | undefined
229
233
  | Record<string, boolean>
230
- | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
234
+ | ClassValue[];
231
235
 
232
236
  const SERIALIZABLE: unique symbol;
233
237
  interface SerializableAttributeValue {
@@ -30,7 +30,17 @@ export function insert<T>(
30
30
  parent: MountableElement,
31
31
  accessor: (() => T) | T,
32
32
  marker?: Node | null,
33
- init?: JSX.Element
33
+ init?: JSX.Element,
34
+ options?: {
35
+ /**
36
+ * Live accessor for the slot's logical host in the source tree (portals).
37
+ * Each top-level node the slot manages is tagged with a `_$host` getter
38
+ * backed by this accessor so delegated events retarget correctly.
39
+ */
40
+ host?: () => Node | null;
41
+ /** Defer the insert effect to the queue instead of running it inline. */
42
+ schedule?: boolean;
43
+ }
34
44
  ): JSX.Element;
35
45
  export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
36
46
  export function delegateEvents(eventNames: string[]): void;
@@ -226,8 +226,12 @@ export namespace JSX {
226
226
 
227
227
  export type ClassValue =
228
228
  | string
229
+ | number
230
+ | boolean
231
+ | null
232
+ | undefined
229
233
  | Record<string, boolean>
230
- | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
234
+ | ClassValue[];
231
235
 
232
236
  const SERIALIZABLE: unique symbol;
233
237
  interface SerializableAttributeValue {