short-circuit in both directions

pull/12285/head
Rich Harris 2 years ago
parent c111767d6d
commit ff38729fc2

@ -13,14 +13,19 @@ export class SvelteURLSearchParams extends URLSearchParams {
#update_url() { #update_url() {
if (!this.#url || this.#updating) return; if (!this.#url || this.#updating) return;
this.#updating = true;
const search = this.toString(); const search = this.toString();
this.#url.search = search && `?${search}`; this.#url.search = search && `?${search}`;
this.#updating = false;
} }
/** /**
* @param {URLSearchParams} params * @param {URLSearchParams} params
*/ */
[REPLACE](params) { [REPLACE](params) {
if (this.#updating) return;
this.#updating = true; this.#updating = true;
for (const key of [...super.keys()]) { for (const key of [...super.keys()]) {
@ -32,7 +37,6 @@ export class SvelteURLSearchParams extends URLSearchParams {
} }
increment(this.#version); increment(this.#version);
this.#updating = false; this.#updating = false;
} }

Loading…
Cancel
Save