solid-js 1.4.2 → 1.4.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.
@@ -1,6 +1,6 @@
1
1
  const $RAW = Symbol("state-raw");
2
2
  function isWrappable(obj) {
3
- return obj != null && typeof obj === "object" && (obj.__proto__ === Object.prototype || Array.isArray(obj));
3
+ return obj != null && typeof obj === "object" && (Object.getPrototypeOf(obj) === Object.prototype || Array.isArray(obj));
4
4
  }
5
5
  function unwrap(item) {
6
6
  return item;
@@ -18,6 +18,19 @@ function mergeStoreNode(state, value, force) {
18
18
  setProperty(state, key, value[key], force);
19
19
  }
20
20
  }
21
+ function updateArray(current, next) {
22
+ if (typeof next === "function") next = next(current);
23
+ if (Array.isArray(next)) {
24
+ if (current === next) return;
25
+ let i = 0,
26
+ len = next.length;
27
+ for (; i < len; i++) {
28
+ const value = next[i];
29
+ if (current[i] !== value) setProperty(current, i, value);
30
+ }
31
+ setProperty(current, "length", len);
32
+ } else mergeStoreNode(current, next);
33
+ }
21
34
  function updatePath(current, path, traversed = []) {
22
35
  let part,
23
36
  next = current;
@@ -63,8 +76,9 @@ function updatePath(current, path, traversed = []) {
63
76
  } else setProperty(current, part, value);
64
77
  }
65
78
  function createStore(state) {
79
+ const isArray = Array.isArray(state);
66
80
  function setStore(...args) {
67
- updatePath(state, args);
81
+ isArray && args.length === 1 ? updateArray(state, args[0]) : updatePath(state, args);
68
82
  }
69
83
  return [state, setStore];
70
84
  }
@@ -28,7 +28,8 @@ function wrap$1(value, name) {
28
28
  return p;
29
29
  }
30
30
  function isWrappable(obj) {
31
- return obj != null && typeof obj === "object" && (obj[solidJs.$PROXY] || !obj.__proto__ || obj.__proto__ === Object.prototype || Array.isArray(obj));
31
+ let proto;
32
+ return obj != null && typeof obj === "object" && (obj[solidJs.$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
32
33
  }
33
34
  function unwrap(item, set = new Set()) {
34
35
  let result, unwrapped, v, prop;
@@ -138,14 +139,16 @@ function mergeStoreNode(state, value) {
138
139
  function updateArray(current, next) {
139
140
  if (typeof next === "function") next = next(current);
140
141
  next = unwrap(next);
141
- if (current === next) return;
142
- let i = 0,
143
- len = next.length;
144
- for (; i < len; i++) {
145
- const value = next[i];
146
- if (current[i] !== value) setProperty(current, i, value);
147
- }
148
- setProperty(current, "length", len);
142
+ if (Array.isArray(next)) {
143
+ if (current === next) return;
144
+ let i = 0,
145
+ len = next.length;
146
+ for (; i < len; i++) {
147
+ const value = next[i];
148
+ if (current[i] !== value) setProperty(current, i, value);
149
+ }
150
+ setProperty(current, "length", len);
151
+ } else mergeStoreNode(current, next);
149
152
  }
150
153
  function updatePath(current, path, traversed = []) {
151
154
  let part,
@@ -192,7 +195,7 @@ function updatePath(current, path, traversed = []) {
192
195
  mergeStoreNode(prev, value);
193
196
  } else setProperty(current, part, value);
194
197
  }
195
- function createStore(store, options) {
198
+ function createStore(...[store, options]) {
196
199
  const unwrappedStore = unwrap(store || {});
197
200
  const isArray = Array.isArray(unwrappedStore);
198
201
  const wrappedStore = wrap$1(unwrappedStore);
@@ -269,11 +272,15 @@ function modifyMutable(state, modifier) {
269
272
  solidJs.batch(() => modifier(unwrap(state)));
270
273
  }
271
274
 
275
+ const $ROOT = Symbol("store-root");
272
276
  function applyState(target, parent, property, merge, key) {
273
277
  const previous = parent[property];
274
278
  if (target === previous) return;
275
279
  if (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key]) {
276
- target !== previous && setProperty(parent, property, target);
280
+ if (target !== previous) {
281
+ if (property === $ROOT) return target;
282
+ setProperty(parent, property, target);
283
+ }
277
284
  return;
278
285
  }
279
286
  if (Array.isArray(target)) {
@@ -345,17 +352,19 @@ function reconcile(value, options = {}) {
345
352
  v = unwrap(value);
346
353
  return state => {
347
354
  if (!isWrappable(state) || !isWrappable(v)) return v;
348
- solidJs.batch(() => applyState(v, {
349
- state
350
- }, "state", merge, key));
351
- return state;
355
+ const res = applyState(v, {
356
+ [$ROOT]: state
357
+ }, $ROOT, merge, key);
358
+ return res === undefined ? state : res;
352
359
  };
353
360
  }
361
+ const producers = new WeakMap();
354
362
  const setterTraps = {
355
363
  get(target, property) {
356
364
  if (property === $RAW) return target;
357
365
  const value = target[property];
358
- return isWrappable(value) ? new Proxy(value, setterTraps) : value;
366
+ let proxy;
367
+ return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
359
368
  },
360
369
  set(target, property, value) {
361
370
  setProperty(target, property, unwrap(value));
@@ -368,7 +377,13 @@ const setterTraps = {
368
377
  };
369
378
  function produce(fn) {
370
379
  return state => {
371
- if (isWrappable(state)) fn(new Proxy(state, setterTraps));
380
+ if (isWrappable(state)) {
381
+ let proxy;
382
+ if (!(proxy = producers.get(state))) {
383
+ producers.set(state, proxy = new Proxy(state, setterTraps));
384
+ }
385
+ fn(proxy);
386
+ }
372
387
  return state;
373
388
  };
374
389
  }
@@ -24,7 +24,8 @@ function wrap$1(value, name) {
24
24
  return p;
25
25
  }
26
26
  function isWrappable(obj) {
27
- return obj != null && typeof obj === "object" && (obj[$PROXY] || !obj.__proto__ || obj.__proto__ === Object.prototype || Array.isArray(obj));
27
+ let proto;
28
+ return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
28
29
  }
29
30
  function unwrap(item, set = new Set()) {
30
31
  let result, unwrapped, v, prop;
@@ -134,14 +135,16 @@ function mergeStoreNode(state, value) {
134
135
  function updateArray(current, next) {
135
136
  if (typeof next === "function") next = next(current);
136
137
  next = unwrap(next);
137
- if (current === next) return;
138
- let i = 0,
139
- len = next.length;
140
- for (; i < len; i++) {
141
- const value = next[i];
142
- if (current[i] !== value) setProperty(current, i, value);
143
- }
144
- setProperty(current, "length", len);
138
+ if (Array.isArray(next)) {
139
+ if (current === next) return;
140
+ let i = 0,
141
+ len = next.length;
142
+ for (; i < len; i++) {
143
+ const value = next[i];
144
+ if (current[i] !== value) setProperty(current, i, value);
145
+ }
146
+ setProperty(current, "length", len);
147
+ } else mergeStoreNode(current, next);
145
148
  }
146
149
  function updatePath(current, path, traversed = []) {
147
150
  let part,
@@ -188,7 +191,7 @@ function updatePath(current, path, traversed = []) {
188
191
  mergeStoreNode(prev, value);
189
192
  } else setProperty(current, part, value);
190
193
  }
191
- function createStore(store, options) {
194
+ function createStore(...[store, options]) {
192
195
  const unwrappedStore = unwrap(store || {});
193
196
  const isArray = Array.isArray(unwrappedStore);
194
197
  const wrappedStore = wrap$1(unwrappedStore);
@@ -265,11 +268,15 @@ function modifyMutable(state, modifier) {
265
268
  batch(() => modifier(unwrap(state)));
266
269
  }
267
270
 
271
+ const $ROOT = Symbol("store-root");
268
272
  function applyState(target, parent, property, merge, key) {
269
273
  const previous = parent[property];
270
274
  if (target === previous) return;
271
275
  if (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key]) {
272
- target !== previous && setProperty(parent, property, target);
276
+ if (target !== previous) {
277
+ if (property === $ROOT) return target;
278
+ setProperty(parent, property, target);
279
+ }
273
280
  return;
274
281
  }
275
282
  if (Array.isArray(target)) {
@@ -341,17 +348,19 @@ function reconcile(value, options = {}) {
341
348
  v = unwrap(value);
342
349
  return state => {
343
350
  if (!isWrappable(state) || !isWrappable(v)) return v;
344
- batch(() => applyState(v, {
345
- state
346
- }, "state", merge, key));
347
- return state;
351
+ const res = applyState(v, {
352
+ [$ROOT]: state
353
+ }, $ROOT, merge, key);
354
+ return res === undefined ? state : res;
348
355
  };
349
356
  }
357
+ const producers = new WeakMap();
350
358
  const setterTraps = {
351
359
  get(target, property) {
352
360
  if (property === $RAW) return target;
353
361
  const value = target[property];
354
- return isWrappable(value) ? new Proxy(value, setterTraps) : value;
362
+ let proxy;
363
+ return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
355
364
  },
356
365
  set(target, property, value) {
357
366
  setProperty(target, property, unwrap(value));
@@ -364,7 +373,13 @@ const setterTraps = {
364
373
  };
365
374
  function produce(fn) {
366
375
  return state => {
367
- if (isWrappable(state)) fn(new Proxy(state, setterTraps));
376
+ if (isWrappable(state)) {
377
+ let proxy;
378
+ if (!(proxy = producers.get(state))) {
379
+ producers.set(state, proxy = new Proxy(state, setterTraps));
380
+ }
381
+ fn(proxy);
382
+ }
368
383
  return state;
369
384
  };
370
385
  }
@@ -1,7 +1,6 @@
1
- import { DeepMutable } from "./store";
2
1
  export declare type ReconcileOptions = {
3
2
  key?: string | null;
4
3
  merge?: boolean;
5
4
  };
6
5
  export declare function reconcile<T extends U, U>(value: T, options?: ReconcileOptions): (state: U) => T;
7
- export declare function produce<T>(fn: (state: DeepMutable<T>) => void): (state: T) => T;
6
+ export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
@@ -1,7 +1,7 @@
1
- import type { DeepMutable, SetStoreFunction, Store } from "store";
1
+ import type { SetStoreFunction, Store } from "store";
2
2
  export declare const $RAW: unique symbol;
3
3
  export declare function isWrappable(obj: any): boolean;
4
- export declare function unwrap<T>(item: any): T;
4
+ export declare function unwrap<T>(item: T): T;
5
5
  export declare function setProperty(state: any, property: PropertyKey, value: any, force?: boolean): void;
6
6
  export declare function updatePath(current: any, path: any[], traversed?: PropertyKey[]): void;
7
7
  export declare function createStore<T>(state: T | Store<T>): [Store<T>, SetStoreFunction<T>];
@@ -11,5 +11,5 @@ declare type ReconcileOptions = {
11
11
  merge?: boolean;
12
12
  };
13
13
  export declare function reconcile<T extends U, U>(value: T, options?: ReconcileOptions): (state: U) => T;
14
- export declare function produce<T>(fn: (state: DeepMutable<T>) => void): (state: T) => T;
14
+ export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
15
15
  export {};
@@ -5,9 +5,9 @@ export declare namespace SolidStore {
5
5
  }
6
6
  }
7
7
  export declare type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
8
- export declare type Store<T> = DeepReadonly<T>;
9
- export declare function isWrappable(obj: any): any;
10
- export declare function unwrap<T extends StoreNode>(item: any, set?: Set<unknown>): T;
8
+ export declare type Store<T> = T;
9
+ export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
10
+ export declare function unwrap<T>(item: T, set?: Set<unknown>): T;
11
11
  export declare function getDataNodes(target: StoreNode): any;
12
12
  export declare function getDataNode(nodes: Record<string, any>, property: string | symbol, value: any): any;
13
13
  export declare function proxyDescriptor(target: StoreNode, property: PropertyKey): PropertyDescriptor | undefined;
@@ -15,20 +15,27 @@ export declare function trackSelf(target: StoreNode): void;
15
15
  export declare function ownKeys(target: StoreNode): (string | symbol)[];
16
16
  export declare function setProperty(state: StoreNode, property: PropertyKey, value: any): void;
17
17
  export declare function updatePath(current: StoreNode, path: any[], traversed?: PropertyKey[]): void;
18
+ /** @deprecated */
18
19
  export declare type DeepReadonly<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
19
20
  readonly [K in keyof T]: DeepReadonly<T[K]>;
20
21
  };
22
+ /** @deprecated */
21
23
  export declare type DeepMutable<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
22
24
  -readonly [K in keyof T]: DeepMutable<T[K]>;
23
25
  };
26
+ export declare type CustomPartial<T> = T extends readonly unknown[] ? "0" extends keyof T ? {
27
+ [K in Extract<keyof T, `${number}`>]?: T[K];
28
+ } : {
29
+ [x: number]: T[number];
30
+ } : Partial<T>;
24
31
  export declare type StorePathRange = {
25
32
  from?: number;
26
33
  to?: number;
27
34
  by?: number;
28
35
  };
29
- export declare type ArrayFilterFn<T> = (item: DeepReadonly<T>, index: number) => boolean;
30
- export declare type StoreSetter<T, U extends PropertyKey[] = []> = ((prevState: DeepReadonly<T>, traversed: U) => T | Partial<T> | DeepReadonly<T> | Partial<DeepReadonly<T>> | void) | T | Partial<T> | DeepReadonly<T> | Partial<DeepReadonly<T>>;
31
- export declare type Part<T, K extends KeyOf<T> = KeyOf<T>> = [K] extends [never] ? never : K | readonly K[] | ([T] extends [readonly unknown[]] ? ArrayFilterFn<T[number]> | StorePathRange : never);
36
+ export declare type ArrayFilterFn<T> = (item: T, index: number) => boolean;
37
+ export declare type StoreSetter<T, U extends PropertyKey[] = []> = ((prevState: T, traversed: U) => T | CustomPartial<T>) | T | CustomPartial<T>;
38
+ export declare type Part<T, K extends KeyOf<T> = KeyOf<T>> = K | ([K] extends [never] ? never : readonly K[]) | ([T] extends [readonly unknown[]] ? ArrayFilterFn<T[number]> | StorePathRange : never);
32
39
  declare type W<T> = Exclude<T, NotWrappable>;
33
40
  declare type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [readonly unknown[]] ? number : [T] extends [never] ? never : keyof T : keyof T;
34
41
  declare type Rest<T, U extends PropertyKey[]> = [StoreSetter<T, U>] | (0 extends 1 & T ? [...Part<any>[], StoreSetter<any, PropertyKey[]>] : DistributeRest<W<T>, KeyOf<W<T>>, U>);
@@ -48,7 +55,9 @@ export interface SetStoreFunction<T> {
48
55
  *
49
56
  * @description https://www.solidjs.com/docs/latest/api#createstore
50
57
  */
51
- export declare function createStore<T extends StoreNode>(store: T | Store<T>, options?: {
58
+ export declare function createStore<T extends {}>(...[store, options]: {} extends T ? [store?: T | Store<T>, options?: {
52
59
  name?: string;
53
- }): [get: Store<T>, set: SetStoreFunction<T>];
60
+ }] : [store: object & (T | Store<T>), options?: {
61
+ name?: string;
62
+ }]): [get: Store<T>, set: SetStoreFunction<T>];
54
63
  export {};
@@ -11,6 +11,7 @@ export declare let Transition: TransitionState | null;
11
11
  declare let ExternalSourceFactory: ExternalSourceFactory | null;
12
12
  declare global {
13
13
  var _$afterUpdate: () => void;
14
+ var _$afterCreateRoot: (root: Owner) => void;
14
15
  }
15
16
  export interface SignalState<T> {
16
17
  value?: T;
@@ -200,13 +201,12 @@ export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(
200
201
  export interface Resource<T> extends Accessor<T> {
201
202
  loading: boolean;
202
203
  error: any;
203
- latest: T | undefined;
204
+ latest: T;
204
205
  }
205
206
  export declare type ResourceActions<T> = {
206
207
  mutate: Setter<T>;
207
208
  refetch: (info?: unknown) => T | Promise<T> | undefined | null;
208
209
  };
209
- export declare type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
210
210
  export declare type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
211
211
  export declare type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
212
212
  export declare type ResourceFetcherInfo<T> = {
@@ -224,6 +224,10 @@ export declare type ResourceOptions<T> = undefined extends T ? {
224
224
  deferStream?: boolean;
225
225
  onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
226
226
  };
227
+ export declare type ResourceReturn<T, O extends ResourceOptions<T | undefined> | undefined, K = T> = [
228
+ Resource<O extends undefined | null ? T | undefined : NonNullable<O>["initialValue"] extends undefined ? T | undefined : T>,
229
+ ResourceActions<K>
230
+ ];
227
231
  /**
228
232
  * Creates a resource that wraps a repeated promise in a reactive pattern:
229
233
  * ```typescript
@@ -249,10 +253,10 @@ export declare type ResourceOptions<T> = undefined extends T ? {
249
253
  *
250
254
  * @description https://www.solidjs.com/docs/latest/api#createresource
251
255
  */
252
- export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
253
- export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
254
- export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
255
- export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
256
+ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined, typeof options>;
257
+ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T, typeof options>;
258
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined, typeof options>;
259
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T, typeof options>;
256
260
  export interface DeferredOptions<T> {
257
261
  equals?: false | ((prev: T, next: T) => boolean);
258
262
  name?: string;
@@ -7,7 +7,7 @@ declare type SharedConfig = {
7
7
  resources?: {
8
8
  [key: string]: any;
9
9
  };
10
- load?: (id: string) => Promise<any> | undefined;
10
+ load?: (id: string) => Promise<any> | any | undefined;
11
11
  gather?: (key: string) => void;
12
12
  registry?: Map<string, Element>;
13
13
  done?: boolean;
package/web/dist/dev.cjs CHANGED
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var solidJs = require('solid-js');
6
6
 
7
7
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
8
- const Properties = new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
9
- const ChildProperties = new Set(["innerHTML", "textContent", "innerText", "children"]);
8
+ const Properties = /*#__PURE__*/new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
9
+ const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
10
10
  const Aliases = {
11
11
  className: "class",
12
12
  htmlFor: "for"
@@ -19,8 +19,8 @@ const PropAliases = {
19
19
  playsinline: "playsInline",
20
20
  readonly: "readOnly"
21
21
  };
22
- const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
23
- const SVGElements = new Set([
22
+ 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"]);
23
+ const SVGElements = /*#__PURE__*/new Set([
24
24
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "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",
25
25
  "set", "stop",
26
26
  "svg", "switch", "symbol", "text", "textPath",
@@ -29,7 +29,7 @@ const SVGNamespace = {
29
29
  xlink: "http://www.w3.org/1999/xlink",
30
30
  xml: "http://www.w3.org/XML/1998/namespace"
31
31
  };
32
- const DOMElements = new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input"]);
32
+ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input"]);
33
33
 
34
34
  function memo(fn, equals) {
35
35
  return solidJs.createMemo(fn, undefined, !equals ? {
@@ -146,7 +146,8 @@ function addEventListener(node, name, handler, delegate) {
146
146
  node[`$$${name}Data`] = handler[1];
147
147
  } else node[`$$${name}`] = handler;
148
148
  } else if (Array.isArray(handler)) {
149
- node.addEventListener(name, e => handler[0](handler[1], e));
149
+ const handlerFn = handler[0];
150
+ node.addEventListener(name, handler[0] = e => handlerFn.call(node, handler[1], e));
150
151
  } else node.addEventListener(name, handler);
151
152
  }
152
153
  function classList(node, value, prev = {}) {
@@ -310,14 +311,24 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
310
311
  value(node);
311
312
  }
312
313
  } else if (prop.slice(0, 3) === "on:") {
313
- node.addEventListener(prop.slice(3), value);
314
+ const e = prop.slice(3);
315
+ prev && node.removeEventListener(e, prev);
316
+ value && node.addEventListener(e, value);
314
317
  } else if (prop.slice(0, 10) === "oncapture:") {
315
- node.addEventListener(prop.slice(10), value, true);
318
+ const e = prop.slice(10);
319
+ prev && node.removeEventListener(e, prev, true);
320
+ value && node.addEventListener(e, value, true);
316
321
  } else if (prop.slice(0, 2) === "on") {
317
322
  const name = prop.slice(2).toLowerCase();
318
323
  const delegate = DelegatedEvents.has(name);
319
- addEventListener(node, name, value, delegate);
320
- delegate && delegateEvents([name]);
324
+ if (!delegate && prev) {
325
+ const h = Array.isArray(prev) ? prev[0] : prev;
326
+ node.removeEventListener(name, h);
327
+ }
328
+ if (delegate || value) {
329
+ addEventListener(node, name, value, delegate);
330
+ delegate && delegateEvents([name]);
331
+ }
321
332
  } else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
322
333
  if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
323
334
  } else {
@@ -349,7 +360,7 @@ function eventHandler(e) {
349
360
  const handler = node[key];
350
361
  if (handler && !node.disabled) {
351
362
  const data = node[`${key}Data`];
352
- data !== undefined ? handler(data, e) : handler(e);
363
+ data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
353
364
  if (e.cancelBubble) return;
354
365
  }
355
366
  node = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode;
@@ -397,7 +408,8 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
397
408
  return () => current;
398
409
  } else if (Array.isArray(value)) {
399
410
  const array = [];
400
- if (normalizeIncomingArray(array, value, unwrapArray)) {
411
+ const currentArray = current && Array.isArray(current);
412
+ if (normalizeIncomingArray(array, value, current, unwrapArray)) {
401
413
  solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
402
414
  return () => current;
403
415
  }
@@ -409,7 +421,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
409
421
  if (array.length === 0) {
410
422
  current = cleanChildren(parent, current, marker);
411
423
  if (multi) return current;
412
- } else if (Array.isArray(current)) {
424
+ } else if (currentArray) {
413
425
  if (current.length === 0) {
414
426
  appendNodes(parent, array, marker);
415
427
  } else reconcileArrays(parent, current, array);
@@ -430,26 +442,30 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
430
442
  } else console.warn(`Unrecognized value. Skipped inserting`, value);
431
443
  return current;
432
444
  }
433
- function normalizeIncomingArray(normalized, array, unwrap) {
445
+ function normalizeIncomingArray(normalized, array, current, unwrap) {
434
446
  let dynamic = false;
435
447
  for (let i = 0, len = array.length; i < len; i++) {
436
448
  let item = array[i],
449
+ prev = current && current[i],
437
450
  t;
438
451
  if (item instanceof Node) {
439
452
  normalized.push(item);
440
453
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
441
- dynamic = normalizeIncomingArray(normalized, item) || dynamic;
442
- } else if ((t = typeof item) === "string") {
443
- normalized.push(document.createTextNode(item));
444
- } else if (t === "function") {
454
+ dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
455
+ } else if ((t = typeof item) === "function") {
445
456
  if (unwrap) {
446
457
  while (typeof item === "function") item = item();
447
- dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
458
+ dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], prev) || dynamic;
448
459
  } else {
449
460
  normalized.push(item);
450
461
  dynamic = true;
451
462
  }
452
- } else normalized.push(document.createTextNode(item.toString()));
463
+ } else {
464
+ const value = t === "string" ? item : item.string();
465
+ if (prev && prev.nodeType === 3 && prev.data === value) {
466
+ normalized.push(prev);
467
+ } else normalized.push(document.createTextNode(value));
468
+ }
453
469
  }
454
470
  return dynamic;
455
471
  }
@@ -508,7 +524,7 @@ function resolveSSRNode(node) {}
508
524
  function ssrClassList(value) {}
509
525
  function ssrStyle(value) {}
510
526
  function ssrSpread(accessor) {}
511
- function ssrBoolean(key, value) {}
527
+ function ssrAttribute(key, value) {}
512
528
  function ssrHydrationKey() {}
513
529
  function escape(html) {}
514
530
  function generateHydrationScript() {}
@@ -561,8 +577,9 @@ function Portal(props) {
561
577
  }
562
578
  function Dynamic(props) {
563
579
  const [p, others] = solidJs.splitProps(props, ["component"]);
580
+ const cached = solidJs.createMemo(() => p.component);
564
581
  return solidJs.createMemo(() => {
565
- const component = p.component;
582
+ const component = cached();
566
583
  switch (typeof component) {
567
584
  case "function":
568
585
  Object.assign(component, {
@@ -667,7 +684,7 @@ exports.setAttribute = setAttribute;
667
684
  exports.setAttributeNS = setAttributeNS;
668
685
  exports.spread = spread;
669
686
  exports.ssr = ssr;
670
- exports.ssrBoolean = ssrBoolean;
687
+ exports.ssrAttribute = ssrAttribute;
671
688
  exports.ssrClassList = ssrClassList;
672
689
  exports.ssrHydrationKey = ssrHydrationKey;
673
690
  exports.ssrSpread = ssrSpread;