sync search on searchParams change because of how node18 handles it

pull/12285/head
FoHoOV 2 years ago
parent 53bb6a8069
commit abcc8c482c

@ -34,8 +34,8 @@ export class SvelteURLSearchParams extends URLSearchParams {
*/
append(name, value) {
var res = super.append(name, value);
increment(this.#version);
this[onChange]?.('append', name, value);
increment(this.#version);
return res;
}
@ -48,8 +48,8 @@ export class SvelteURLSearchParams extends URLSearchParams {
var has_value = super.has(name, value);
var res = super.delete(name, value);
if (has_value) {
increment(this.#version);
this[onChange]?.('delete', name, value);
increment(this.#version);
}
return res;
}
@ -98,15 +98,15 @@ export class SvelteURLSearchParams extends URLSearchParams {
// can't use has(name, value), because for something like https://svelte.dev?foo=1&bar=2&foo=3
// if you set `foo` to 1, then foo=3 gets deleted whilst `has("foo", "1")` returns true
if (value_before_change !== super.getAll(name).join('')) {
increment(this.#version);
this[onChange]?.('set', name, value);
increment(this.#version);
}
}
sort() {
var res = super.sort();
increment(this.#version);
this[onChange]?.('sort');
increment(this.#version);
return res;
}

@ -21,6 +21,9 @@ export class SvelteURL extends URL {
super(url);
this.#searchParams[REPLACE](url.searchParams);
this.#searchParams[onChange] = (command, ...args) => {
if (this.search !== super.search) {
super.search = this.search;
}
if (this.#searchParams.toString() === super.searchParams.toString()) {
return;
}

Loading…
Cancel
Save