@wcstack/router 4.7.0 → 4.8.0
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/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +29 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -791,6 +791,10 @@ declare class Head extends HTMLElement {
|
|
|
791
791
|
connectedCallback(): void;
|
|
792
792
|
disconnectedCallback(): void;
|
|
793
793
|
get childElementArray(): Element[];
|
|
794
|
+
/**
|
|
795
|
+
* head へ入れる子のクローン。束縛を持つ子は、束ねたクローンを使い回す(boundClones)
|
|
796
|
+
*/
|
|
797
|
+
private _cloneOf;
|
|
794
798
|
/**
|
|
795
799
|
* 要素の一意キーを生成(WeakMap でキャッシュ)
|
|
796
800
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -4192,6 +4192,14 @@ let initialHeadCaptured = false;
|
|
|
4192
4192
|
* 要素の属性変更には追随しない(Head 内要素は初期化時に固定される前提)。
|
|
4193
4193
|
*/
|
|
4194
4194
|
const keyCache = new WeakMap();
|
|
4195
|
+
/**
|
|
4196
|
+
* 束縛を持つ子ごとに、head へ入れる束ねたクローンを 1 つだけ持つ。
|
|
4197
|
+
* binder には束縛を解く口が無く(docs/binder-protocol-design.md §6-2)、state は束ねたノードを
|
|
4198
|
+
* エンジンの寿命まで持つ。遷移のたびに新しいクローンを束ねさせると、外したクローンが 1 つずつ
|
|
4199
|
+
* 残った(束ねた `<title>` で遷移ごとに 2 ノード — docs/seam-apps.md、shift-desk)。同じクローンを
|
|
4200
|
+
* 入れ直せば、bind は冪等で、外れている間も値は届いている。
|
|
4201
|
+
*/
|
|
4202
|
+
const boundClones = new WeakMap();
|
|
4195
4203
|
class Head extends HTMLElement {
|
|
4196
4204
|
_initialized = false;
|
|
4197
4205
|
_childElementArray = [];
|
|
@@ -4243,6 +4251,20 @@ class Head extends HTMLElement {
|
|
|
4243
4251
|
}
|
|
4244
4252
|
return this._childElementArray;
|
|
4245
4253
|
}
|
|
4254
|
+
/**
|
|
4255
|
+
* head へ入れる子のクローン。束縛を持つ子は、束ねたクローンを使い回す(boundClones)
|
|
4256
|
+
*/
|
|
4257
|
+
_cloneOf(child) {
|
|
4258
|
+
if (!hasBinding(child)) {
|
|
4259
|
+
return child.cloneNode(true);
|
|
4260
|
+
}
|
|
4261
|
+
let clone = boundClones.get(child);
|
|
4262
|
+
if (clone === undefined) {
|
|
4263
|
+
clone = child.cloneNode(true);
|
|
4264
|
+
boundClones.set(child, clone);
|
|
4265
|
+
}
|
|
4266
|
+
return clone;
|
|
4267
|
+
}
|
|
4246
4268
|
/**
|
|
4247
4269
|
* 要素の一意キーを生成(WeakMap でキャッシュ)
|
|
4248
4270
|
*/
|
|
@@ -4371,7 +4393,7 @@ class Head extends HTMLElement {
|
|
|
4371
4393
|
const head = headStack[i];
|
|
4372
4394
|
for (const child of head._childElementArray) {
|
|
4373
4395
|
if (this._getKey(child) === key) {
|
|
4374
|
-
targetElement =
|
|
4396
|
+
targetElement = this._cloneOf(child);
|
|
4375
4397
|
break;
|
|
4376
4398
|
}
|
|
4377
4399
|
}
|
|
@@ -4386,9 +4408,13 @@ class Head extends HTMLElement {
|
|
|
4386
4408
|
}
|
|
4387
4409
|
// headを更新
|
|
4388
4410
|
const current = headElementMap.get(key) ?? null;
|
|
4411
|
+
// 束ねたクローンが既に入っている(同じ Head の再適用)
|
|
4412
|
+
if (targetElement !== null && current === targetElement) {
|
|
4413
|
+
continue;
|
|
4414
|
+
}
|
|
4389
4415
|
// 同じ要素は入れ直さない。入れ直すとスタイルシートを取り直し、<base> の差し替えは base-uri の
|
|
4390
4416
|
// CSP を毎回検査させる(WebKit は遷移ごとに違反を報告した — docs/seam-apps.md、prod-booking)。
|
|
4391
|
-
//
|
|
4417
|
+
// 束縛を持つ要素は、束ねたクローン(boundClones)が入っていれば上で残した。別の要素が入っていれば入れ直す
|
|
4392
4418
|
if (targetElement && current?.isEqualNode(targetElement) && !hasBinding(targetElement)) {
|
|
4393
4419
|
continue;
|
|
4394
4420
|
}
|
|
@@ -4462,7 +4488,7 @@ function bootstrapRouter(config, registry) {
|
|
|
4462
4488
|
registerComponents(registry);
|
|
4463
4489
|
}
|
|
4464
4490
|
|
|
4465
|
-
var version = "4.
|
|
4491
|
+
var version = "4.8.0";
|
|
4466
4492
|
var pkg = {
|
|
4467
4493
|
version: version};
|
|
4468
4494
|
|