@solidjs/web 2.0.0-beta.13 → 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/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, 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 = {
@@ -30,6 +30,8 @@ const DOMWithState = {
30
30
  }
31
31
  };
32
32
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
33
+ const $$SLOT = /*#__PURE__*/Symbol("slot");
34
+ const $$HOST = /*#__PURE__*/Symbol("host");
33
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"]);
34
36
  const SVGElements = /*#__PURE__*/new Set([
35
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",
@@ -63,14 +65,18 @@ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, optio
63
65
  } : transparentOptions);
64
66
  const memo = fn => createMemo(() => fn(), syncOptions);
65
67
 
66
- function reconcileArrays(parentNode, a, b) {
68
+ function reconcileArrays(parentNode, a, b, marker) {
67
69
  let bLength = b.length,
68
70
  aEnd = a.length,
69
71
  bEnd = bLength,
70
72
  aStart = 0,
71
73
  bStart = 0,
72
- after = a[aEnd - 1].nextSibling,
73
- map = null;
74
+ tail = a[aEnd - 1],
75
+ tailTag = tail[$$SLOT],
76
+ after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
77
+ map = null,
78
+ anchor,
79
+ anchorTag;
74
80
  while (aStart < aEnd || bStart < bEnd) {
75
81
  if (a[aStart] === b[bStart]) {
76
82
  aStart++;
@@ -82,20 +88,43 @@ function reconcileArrays(parentNode, a, b) {
82
88
  bEnd--;
83
89
  }
84
90
  if (aEnd === aStart) {
85
- const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
86
- while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
91
+ let node;
92
+ if (bEnd < bLength) {
93
+ if (bStart) {
94
+ const prev = b[bStart - 1];
95
+ const prevTag = prev[$$SLOT];
96
+ node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
97
+ } else node = b[bEnd - bStart];
98
+ } else node = after;
99
+ while (bStart < bEnd) {
100
+ const n = b[bStart++];
101
+ parentNode.insertBefore(n, node);
102
+ if (marker) n[$$SLOT] = marker;
103
+ }
87
104
  } else if (bEnd === bStart) {
88
105
  while (aStart < aEnd) {
89
- if (!map || !map.has(a[aStart])) a[aStart].remove();
90
- aStart++;
106
+ const n = a[aStart++];
107
+ if (!map || !map.has(n)) {
108
+ const tag = n[$$SLOT];
109
+ if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
110
+ }
111
+ }
112
+ } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
113
+ if (marker) {
114
+ do {
115
+ const n = a[--aEnd];
116
+ parentNode.insertBefore(n, anchor);
117
+ n[$$SLOT] = marker;
118
+ bStart++;
119
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
120
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
121
+ } else {
122
+ do {
123
+ parentNode.insertBefore(a[--aEnd], anchor);
124
+ bStart++;
125
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
126
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
91
127
  }
92
- } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
93
- const anchor = a[aStart];
94
- do {
95
- parentNode.insertBefore(a[--aEnd], anchor);
96
- bStart++;
97
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
98
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
99
128
  } else {
100
129
  if (!map) {
101
130
  map = new Map();
@@ -113,33 +142,63 @@ function reconcileArrays(parentNode, a, b) {
113
142
  sequence++;
114
143
  }
115
144
  if (sequence > index - bStart) {
116
- const node = a[aStart];
117
- while (bStart < index) parentNode.insertBefore(b[bStart++], node);
118
- } else parentNode.replaceChild(b[bStart++], a[aStart++]);
145
+ const head = a[aStart];
146
+ const headTag = head[$$SLOT];
147
+ const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
148
+ while (bStart < index) {
149
+ const n = b[bStart++];
150
+ parentNode.insertBefore(n, node);
151
+ if (marker) n[$$SLOT] = marker;
152
+ }
153
+ } else {
154
+ const oldNode = a[aStart++];
155
+ const newNode = b[bStart++];
156
+ const oldTag = oldNode[$$SLOT];
157
+ if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
158
+ parentNode.replaceChild(newNode, oldNode);
159
+ } else {
160
+ parentNode.insertBefore(newNode, after);
161
+ }
162
+ if (marker) newNode[$$SLOT] = marker;
163
+ }
119
164
  } else aStart++;
120
- } else a[aStart++].remove();
165
+ } else {
166
+ const n = a[aStart++];
167
+ const nTag = n[$$SLOT];
168
+ if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
169
+ }
121
170
  }
122
171
  }
123
172
  }
124
173
 
125
- const $$EVENTS = "_$DX_DELEGATE";
174
+ const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
126
175
  const INNER_OWNED = {};
176
+ const delegatedEvents = new Set();
177
+ const delegatedContainers = new Map();
127
178
  function render$1(code, element, init, options = {}) {
128
179
  let disposer;
129
- createRoot(dispose => {
130
- disposer = dispose;
131
- if (element === document) {
132
- const tree = code();
133
- effect(() => flatten(tree), () => {});
134
- } else {
135
- const tree = code();
136
- insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
137
- }
138
- }, {
139
- id: options.renderId
140
- });
180
+ registerDelegatedRoot(element);
181
+ try {
182
+ createRoot(dispose => {
183
+ disposer = dispose;
184
+ if (element === document) {
185
+ const tree = code();
186
+ effect(() => flatten(tree), () => {});
187
+ } else {
188
+ const tree = code();
189
+ insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
190
+ }
191
+ }, {
192
+ id: options.renderId
193
+ });
194
+ } catch (err) {
195
+ if (disposer) disposer();
196
+ unregisterDelegatedRoot(element);
197
+ throw err;
198
+ }
141
199
  return () => {
142
200
  disposer();
201
+ unregisterDelegatedRoot(element);
143
202
  element.textContent = "";
144
203
  };
145
204
  }
@@ -153,20 +212,66 @@ function template(html, flag) {
153
212
  const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
154
213
  return fn;
155
214
  }
156
- function delegateEvents(eventNames, document = window.document) {
157
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
215
+ function delegateEvents(eventNames) {
158
216
  for (let i = 0, l = eventNames.length; i < l; i++) {
159
217
  const name = eventNames[i];
160
- if (!e.has(name)) {
161
- e.add(name);
162
- document.addEventListener(name, eventHandler);
218
+ if (!delegatedEvents.has(name)) {
219
+ delegatedEvents.add(name);
220
+ delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
163
221
  }
164
222
  }
165
223
  }
166
- function clearDelegatedEvents(document = window.document) {
167
- if (document[$$EVENTS]) {
168
- for (let name of document[$$EVENTS].keys()) document.removeEventListener(name, eventHandler);
169
- delete document[$$EVENTS];
224
+ function registerDelegatedRoot(root) {
225
+ const state = registerDelegatedContainer(root, root);
226
+ if (state) state.roots = (state.roots || 0) + 1;
227
+ }
228
+ function unregisterDelegatedRoot(root) {
229
+ const state = delegatedContainers.get(root);
230
+ if (state) state.roots > 1 ? state.roots-- : delete state.roots;
231
+ unregisterDelegatedContainer(root, root);
232
+ }
233
+ function registerDelegatedContainer(container, owner = container) {
234
+ if (!container || !owner) return;
235
+ let state = delegatedContainers.get(container);
236
+ if (!state) delegatedContainers.set(container, state = {
237
+ owners: new Map(),
238
+ handlers: new Map()
239
+ });
240
+ state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
241
+ delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
242
+ return state;
243
+ }
244
+ function unregisterDelegatedContainer(container, owner = container) {
245
+ const state = delegatedContainers.get(container);
246
+ if (!state) return;
247
+ const count = state.owners.get(owner);
248
+ if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
249
+ if (state.owners.size) return;
250
+ state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
251
+ delegatedContainers.delete(container);
252
+ }
253
+ function attachDelegatedEvent(name, container, state) {
254
+ if (state.handlers.has(name)) return;
255
+ const handler = e => eventHandler(e, container, state);
256
+ state.handlers.set(name, handler);
257
+ container.addEventListener(name, handler);
258
+ }
259
+ function getDelegatedRoot(node) {
260
+ while (node) {
261
+ if (delegatedContainers.get(node)?.roots) return node;
262
+ node = node._$host || node.parentNode || node.host;
263
+ }
264
+ }
265
+ function findOwner(target, state) {
266
+ let node = target;
267
+ let distance = 0;
268
+ while (node) {
269
+ if (state.owners.has(node)) return {
270
+ owner: node,
271
+ distance
272
+ };
273
+ distance++;
274
+ node = node._$host || node.parentNode || node.host;
170
275
  }
171
276
  }
172
277
  function setProperty(node, name, value) {
@@ -211,7 +316,7 @@ function className(node, value, prev) {
211
316
  node.classList.add(key);
212
317
  }
213
318
  }
214
- function addEventListener(node, name, handler, delegate) {
319
+ function addEvent(node, name, handler, delegate) {
215
320
  if (delegate) {
216
321
  if (Array.isArray(handler)) {
217
322
  node[`$$${name}`] = handler[0];
@@ -278,6 +383,7 @@ function ref(fn, element) {
278
383
  }
279
384
  function insert(parent, accessor, marker, initial, options) {
280
385
  const multi = marker !== undefined;
386
+ const host = options && options.host;
281
387
  if (multi && !initial) initial = [];
282
388
  if (isHydrating(parent)) {
283
389
  if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
@@ -291,7 +397,11 @@ function insert(parent, accessor, marker, initial, options) {
291
397
  }
292
398
  if (typeof accessor !== "function") {
293
399
  accessor = normalize(accessor, initial, multi, true);
294
- 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
+ }
295
405
  }
296
406
  if (multi && initial.length === 0) {
297
407
  const placeholder = document.createTextNode("");
@@ -305,6 +415,7 @@ function insert(parent, accessor, marker, initial, options) {
305
415
  effect(() => normalize(value, current, multi), inner => {
306
416
  insertExpression(parent, inner, current, marker);
307
417
  current = inner;
418
+ host && tagHost(current, host);
308
419
  }, prev !== undefined && !(options && options.schedule) ? {
309
420
  ...options,
310
421
  schedule: true
@@ -314,6 +425,7 @@ function insert(parent, accessor, marker, initial, options) {
314
425
  if (value === INNER_OWNED) return;
315
426
  insertExpression(parent, value, current, marker);
316
427
  current = value;
428
+ host && tagHost(current, host);
317
429
  }, options);
318
430
  }
319
431
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
@@ -461,7 +573,17 @@ function runHydrationEvents() {
461
573
  const [el, e] = events[0];
462
574
  if (!completed.has(el)) return;
463
575
  events.shift();
464
- eventHandler(e);
576
+ let match;
577
+ for (const [container, state] of delegatedContainers) {
578
+ if (!state.handlers.has(e.type)) continue;
579
+ const entry = findOwner(e.target, state);
580
+ if (entry && (!match || entry.distance < match.distance)) match = {
581
+ container,
582
+ state,
583
+ distance: entry.distance
584
+ };
585
+ }
586
+ if (match) eventHandler(e, match.container, match.state);
465
587
  }
466
588
  if (sharedConfig.done) {
467
589
  sharedConfig.events = _$HY.events = null;
@@ -516,7 +638,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
516
638
  node.removeEventListener(name, h);
517
639
  }
518
640
  if (delegate || value) {
519
- addEventListener(node, name, value, delegate);
641
+ addEvent(node, name, value, delegate);
520
642
  delegate && delegateEvents([name]);
521
643
  }
522
644
  } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
@@ -528,14 +650,18 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
528
650
  }
529
651
  return value;
530
652
  }
531
- function eventHandler(e) {
653
+ function eventHandler(e, container, state) {
532
654
  if (sharedConfig.registry && sharedConfig.events) {
533
655
  if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
534
656
  }
657
+ if (e[$$EVENT_OWNER]) return;
658
+ const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
659
+ if (state && !owner) return;
660
+ e[$$EVENT_OWNER] = owner || true;
535
661
  let node = e.target;
536
662
  const key = `$$${e.type}`;
537
663
  const oriTarget = e.target;
538
- const oriCurrentTarget = e.currentTarget;
664
+ const boundary = owner || container || e.currentTarget;
539
665
  const retarget = value => Object.defineProperty(e, "target", {
540
666
  configurable: true,
541
667
  value
@@ -551,29 +677,34 @@ function eventHandler(e) {
551
677
  return true;
552
678
  };
553
679
  const walkUpTree = () => {
554
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
680
+ while (handleNode()) {
681
+ if (node === boundary || node.parentNode === boundary) break;
682
+ node = node._$host || node.parentNode || node.host;
683
+ }
555
684
  };
556
685
  Object.defineProperty(e, "currentTarget", {
557
686
  configurable: true,
558
687
  get() {
559
- return node || document;
688
+ return node || boundary || document;
560
689
  }
561
690
  });
562
691
  if (e.composedPath) {
563
692
  const path = e.composedPath();
564
- retarget(path[0]);
565
- for (let i = 0; i < path.length - 2; i++) {
566
- node = path[i];
567
- if (!handleNode()) break;
568
- if (node._$host) {
569
- node = node._$host;
570
- walkUpTree();
571
- break;
572
- }
573
- if (node.parentNode === oriCurrentTarget) {
574
- break;
693
+ if (path.length) {
694
+ retarget(path[0]);
695
+ for (let i = 0; i < path.length; i++) {
696
+ node = path[i];
697
+ if (!handleNode()) break;
698
+ if (node._$host) {
699
+ node = node._$host;
700
+ walkUpTree();
701
+ break;
702
+ }
703
+ if (node === boundary || node.parentNode === boundary) {
704
+ break;
705
+ }
575
706
  }
576
- }
707
+ } else walkUpTree();
577
708
  }
578
709
  else walkUpTree();
579
710
  retarget(oriTarget);
@@ -593,9 +724,14 @@ function insertExpression(parent, value, current, marker) {
593
724
  } else if (value.nodeType) {
594
725
  if (Array.isArray(current)) {
595
726
  cleanChildren(parent, current, multi ? marker : null, value);
596
- } else if (current === undefined || !parent.firstChild) {
727
+ } else if (current && current.nodeType) {
728
+ current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
729
+ } else if (current && parent.firstChild) {
730
+ parent.replaceChild(value, parent.firstChild);
731
+ } else {
597
732
  parent.appendChild(value);
598
- } else parent.replaceChild(value, parent.firstChild);
733
+ }
734
+ if (marker) value[$$SLOT] = marker;
599
735
  } else if (Array.isArray(value)) {
600
736
  const currentArray = current && Array.isArray(current);
601
737
  if (value.length === 0) {
@@ -603,7 +739,7 @@ function insertExpression(parent, value, current, marker) {
603
739
  } else if (currentArray) {
604
740
  if (current.length === 0) {
605
741
  appendNodes(parent, value, marker);
606
- } else reconcileArrays(parent, current, value);
742
+ } else reconcileArrays(parent, current, value, marker);
607
743
  } else {
608
744
  current && cleanChildren(parent);
609
745
  appendNodes(parent, value);
@@ -627,8 +763,23 @@ function normalize(value, current, multi, doNotUnwrap) {
627
763
  }
628
764
  return value;
629
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
+ }
630
777
  function appendNodes(parent, array, marker = null) {
631
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
778
+ for (let i = 0, len = array.length; i < len; i++) {
779
+ const n = array[i];
780
+ parent.insertBefore(n, marker);
781
+ if (marker) n[$$SLOT] = marker;
782
+ }
632
783
  }
633
784
  function cleanChildren(parent, current, marker, replacement) {
634
785
  if (marker === undefined) return parent.textContent = "";
@@ -637,11 +788,13 @@ function cleanChildren(parent, current, marker, replacement) {
637
788
  for (let i = current.length - 1; i >= 0; i--) {
638
789
  const el = current[i];
639
790
  if (replacement !== el) {
640
- const isParent = el.parentNode === parent;
641
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
791
+ const tag = el[$$SLOT];
792
+ const owns = el.parentNode === parent && (!tag || tag === marker);
793
+ if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
642
794
  } else inserted = true;
643
795
  }
644
796
  } else if (replacement) parent.insertBefore(replacement, marker);
797
+ if (replacement && marker) replacement[$$SLOT] = marker;
645
798
  }
646
799
  function gatherHydratable(element, root) {
647
800
  const templates = element.querySelectorAll(`*[_hk]`);
@@ -703,12 +856,20 @@ function Portal(props) {
703
856
  const treeMarker = document.createTextNode(""),
704
857
  startMarker = document.createTextNode(""),
705
858
  endMarker = document.createTextNode(""),
706
- mount = () => createElementProxy(props.mount || document.body, treeMarker);
707
- let content = createMemo(() => [startMarker, props.children]);
708
- createRenderEffect(() => [mount(), content()], ([m, c]) => {
859
+ mount = () => props.mount || document.body,
860
+ content = createMemo(() => [startMarker, props.children]);
861
+ createRenderEffect(
862
+ () => [mount(), content(), getOwner()], ([, c, owner]) => {
863
+ const m = untrack(mount);
709
864
  m.appendChild(endMarker);
710
- 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
+ }));
711
871
  return () => {
872
+ dispose();
712
873
  let c = startMarker;
713
874
  while (c && c !== endMarker) {
714
875
  const n = c.nextSibling;
@@ -716,6 +877,15 @@ function Portal(props) {
716
877
  c = n;
717
878
  }
718
879
  };
880
+ }, {
881
+ schedule: true
882
+ });
883
+ createEffect(mount, () => {
884
+ const m = untrack(mount);
885
+ const ownerRoot = getDelegatedRoot(treeMarker);
886
+ if (!ownerRoot || ownerRoot.contains(m)) return;
887
+ registerDelegatedContainer(m, ownerRoot);
888
+ return () => unregisterDelegatedContainer(m, ownerRoot);
719
889
  });
720
890
  return treeMarker;
721
891
  }
@@ -746,22 +916,5 @@ function createElement(tagName, is = undefined) {
746
916
  is
747
917
  });
748
918
  }
749
- function createElementProxy(el, marker) {
750
- return new Proxy(el, {
751
- get(target, prop) {
752
- if (prop === "appendChild" || prop === "insertBefore") {
753
- return (...args) => {
754
- Object.defineProperty(args[0], "_$host", {
755
- get: () => marker.parentNode,
756
- configurable: true
757
- });
758
- target[prop](...args);
759
- };
760
- }
761
- const value = Reflect.get(target, prop);
762
- return typeof value === "function" ? value.bind(target) : value;
763
- }
764
- });
765
- }
766
919
 
767
- export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
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.13",
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.13"
140
+ "solid-js": "^2.0.0-beta.15"
141
141
  },
142
142
  "devDependencies": {
143
- "solid-js": "2.0.0-beta.13"
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,11 +30,31 @@ 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
- export function delegateEvents(eventNames: string[], d?: Document): void;
37
- export function clearDelegatedEvents(d?: Document): void;
46
+ export function delegateEvents(eventNames: string[]): void;
47
+ export function registerDelegatedRoot(root: MountableElement): void;
48
+ export function unregisterDelegatedRoot(root: MountableElement): void;
49
+ export function registerDelegatedContainer(
50
+ container: MountableElement,
51
+ owner?: MountableElement
52
+ ): void;
53
+ export function unregisterDelegatedContainer(
54
+ container: MountableElement,
55
+ owner?: MountableElement
56
+ ): void;
57
+ export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
38
58
  export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
39
59
  export function assign(
40
60
  node: Element,
@@ -45,17 +65,10 @@ export function assign(
45
65
  ): void;
46
66
  export function setAttribute(node: Element, name: string, value: string): void;
47
67
  export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
48
- type ClassList =
49
- | Record<string, boolean>
50
- | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
51
- export function className(
52
- node: Element,
53
- value: string | ClassList,
54
- prev?: string | ClassList
55
- ): void;
68
+ export function className(node: Element, value: JSX.ClassValue, prev?: JSX.ClassValue): void;
56
69
  export function setProperty(node: Element, name: string, value: any): void;
57
70
  export function setStyleProperty(node: Element, name: string, value: any): void;
58
- export function addEventListener(
71
+ export function addEvent(
59
72
  node: Element,
60
73
  name: string,
61
74
  handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions),
@@ -31,6 +31,7 @@ export type PropValue =
31
31
  | MediaSource
32
32
  | Blob
33
33
  | File
34
+ | Date
34
35
  | Element;
35
36
 
36
37
  /**