Revert "more efficient initialisation"

This reverts commit 29d4a8078b.
pull/10803/head
Rich Harris 2 years ago
parent 2d0518ac97
commit 95e92a647b

@ -1,3 +1,4 @@
import { DEV } from 'esm-env';
import { source, set } from '../internal/client/reactivity/sources.js';
import { get } from '../internal/client/runtime.js';
import { UNINITIALIZED } from '../internal/client/constants.js';
@ -17,14 +18,15 @@ export class ReactiveMap extends Map {
* @param {Iterable<readonly [K, V]> | null | undefined} [value]
*/
constructor(value) {
super(value);
super();
// If the value is invalid then the native exception will fire here
if (DEV) new Map(value);
if (value) {
for (var [key, v] of value) {
this.#sources.set(key, source(v));
this.set(key, v);
}
this.#size.v = this.#sources.size;
}
}
@ -76,7 +78,7 @@ export class ReactiveMap extends Map {
/**
* @param {K} key
* @param {V} value
*/
* */
set(key, value) {
var sources = this.#sources;
var s = sources.get(key);

@ -1,3 +1,4 @@
import { DEV } from 'esm-env';
import { source, set } from '../internal/client/reactivity/sources.js';
import { get } from '../internal/client/runtime.js';
import { make_iterable } from './utils.js';
@ -20,14 +21,15 @@ export class ReactiveSet extends Set {
* @param {Iterable<T> | null | undefined} [value]
*/
constructor(value) {
super(value);
super();
// If the value is invalid then the native exception will fire here
if (DEV) new Set(value);
if (value) {
for (var element of value) {
this.#sources.set(element, source(true));
this.add(/** @type {T} */ (element));
}
this.#size.v = this.#sources.size;
}
if (!inited) this.#init();

Loading…
Cancel
Save