phoenix_live_view 1.1.6 → 1.1.8
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/assets/js/phoenix_live_view/view.js +20 -14
- package/assets/js/types/view.d.ts +1 -1
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +15 -10
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +15 -10
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +15 -10
- package/priv/static/phoenix_live_view.min.js +6 -6
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
CONSECUTIVE_RELOADS,
|
|
5
5
|
PHX_AUTO_RECOVER,
|
|
6
6
|
PHX_COMPONENT,
|
|
7
|
+
PHX_VIEW_REF,
|
|
7
8
|
PHX_CONNECTED_CLASS,
|
|
8
9
|
PHX_DISABLE_WITH,
|
|
9
10
|
PHX_DISABLE_WITH_RESTORE,
|
|
@@ -664,7 +665,10 @@ export default class View {
|
|
|
664
665
|
afterElementsRemoved(elements, pruneCids) {
|
|
665
666
|
const destroyedCIDs = [];
|
|
666
667
|
elements.forEach((parent) => {
|
|
667
|
-
const components = DOM.all(
|
|
668
|
+
const components = DOM.all(
|
|
669
|
+
parent,
|
|
670
|
+
`[${PHX_VIEW_REF}="${this.id}"][${PHX_COMPONENT}]`,
|
|
671
|
+
);
|
|
668
672
|
const hooks = DOM.all(
|
|
669
673
|
parent,
|
|
670
674
|
`[${this.binding(PHX_HOOK)}], [data-phx-hook]`,
|
|
@@ -674,7 +678,7 @@ export default class View {
|
|
|
674
678
|
if (
|
|
675
679
|
isCid(cid) &&
|
|
676
680
|
destroyedCIDs.indexOf(cid) === -1 &&
|
|
677
|
-
|
|
681
|
+
el.getAttribute(PHX_VIEW_REF) === this.id
|
|
678
682
|
) {
|
|
679
683
|
destroyedCIDs.push(cid);
|
|
680
684
|
}
|
|
@@ -828,12 +832,16 @@ export default class View {
|
|
|
828
832
|
});
|
|
829
833
|
}
|
|
830
834
|
|
|
831
|
-
update(diff, events) {
|
|
835
|
+
update(diff, events, isPending = false) {
|
|
832
836
|
if (
|
|
833
837
|
this.isJoinPending() ||
|
|
834
838
|
(this.liveSocket.hasPendingLink() && this.root.isMain())
|
|
835
839
|
) {
|
|
836
|
-
|
|
840
|
+
// don't mutate if this is already a pending diff
|
|
841
|
+
if (!isPending) {
|
|
842
|
+
this.pendingDiffs.push({ diff, events });
|
|
843
|
+
}
|
|
844
|
+
return false;
|
|
837
845
|
}
|
|
838
846
|
|
|
839
847
|
this.rendered.mergeDiff(diff);
|
|
@@ -871,6 +879,8 @@ export default class View {
|
|
|
871
879
|
if (phxChildrenAdded) {
|
|
872
880
|
this.joinNewChildren();
|
|
873
881
|
}
|
|
882
|
+
|
|
883
|
+
return true;
|
|
874
884
|
}
|
|
875
885
|
|
|
876
886
|
renderContainer(diff, kind) {
|
|
@@ -981,16 +991,12 @@ export default class View {
|
|
|
981
991
|
}
|
|
982
992
|
|
|
983
993
|
applyPendingUpdates() {
|
|
984
|
-
// prevent race conditions where we might still be pending a new
|
|
985
|
-
// navigation
|
|
986
|
-
// if
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
this.pendingDiffs.forEach(({ diff, events }) => this.update(diff, events));
|
|
993
|
-
this.pendingDiffs = [];
|
|
994
|
+
// To prevent race conditions where we might still be pending a new
|
|
995
|
+
// navigation or the join is still pending, `this.update` returns false
|
|
996
|
+
// if the diff was not applied.
|
|
997
|
+
this.pendingDiffs = this.pendingDiffs.filter(
|
|
998
|
+
({ diff, events }) => !this.update(diff, events, true),
|
|
999
|
+
);
|
|
994
1000
|
this.eachChild((child) => child.applyPendingUpdates());
|
|
995
1001
|
}
|
|
996
1002
|
|
|
@@ -78,7 +78,7 @@ export default class View {
|
|
|
78
78
|
isJoinPending(): boolean;
|
|
79
79
|
ackJoin(_child: any): void;
|
|
80
80
|
onAllChildJoinsComplete(): void;
|
|
81
|
-
update(diff: any, events: any):
|
|
81
|
+
update(diff: any, events: any, isPending?: boolean): boolean;
|
|
82
82
|
renderContainer(diff: any, kind: any): any;
|
|
83
83
|
componentPatch(diff: any, cid: any): boolean;
|
|
84
84
|
getHook(el: any): any;
|
package/package.json
CHANGED
|
@@ -4501,14 +4501,17 @@ var View = class _View {
|
|
|
4501
4501
|
afterElementsRemoved(elements, pruneCids) {
|
|
4502
4502
|
const destroyedCIDs = [];
|
|
4503
4503
|
elements.forEach((parent) => {
|
|
4504
|
-
const components = dom_default.all(
|
|
4504
|
+
const components = dom_default.all(
|
|
4505
|
+
parent,
|
|
4506
|
+
`[${PHX_VIEW_REF}="${this.id}"][${PHX_COMPONENT}]`
|
|
4507
|
+
);
|
|
4505
4508
|
const hooks = dom_default.all(
|
|
4506
4509
|
parent,
|
|
4507
4510
|
`[${this.binding(PHX_HOOK)}], [data-phx-hook]`
|
|
4508
4511
|
);
|
|
4509
4512
|
components.concat(parent).forEach((el) => {
|
|
4510
4513
|
const cid = this.componentID(el);
|
|
4511
|
-
if (isCid(cid) && destroyedCIDs.indexOf(cid) === -1 &&
|
|
4514
|
+
if (isCid(cid) && destroyedCIDs.indexOf(cid) === -1 && el.getAttribute(PHX_VIEW_REF) === this.id) {
|
|
4512
4515
|
destroyedCIDs.push(cid);
|
|
4513
4516
|
}
|
|
4514
4517
|
});
|
|
@@ -4616,9 +4619,12 @@ var View = class _View {
|
|
|
4616
4619
|
this.pendingJoinOps = [];
|
|
4617
4620
|
});
|
|
4618
4621
|
}
|
|
4619
|
-
update(diff, events) {
|
|
4622
|
+
update(diff, events, isPending = false) {
|
|
4620
4623
|
if (this.isJoinPending() || this.liveSocket.hasPendingLink() && this.root.isMain()) {
|
|
4621
|
-
|
|
4624
|
+
if (!isPending) {
|
|
4625
|
+
this.pendingDiffs.push({ diff, events });
|
|
4626
|
+
}
|
|
4627
|
+
return false;
|
|
4622
4628
|
}
|
|
4623
4629
|
this.rendered.mergeDiff(diff);
|
|
4624
4630
|
let phxChildrenAdded = false;
|
|
@@ -4648,6 +4654,7 @@ var View = class _View {
|
|
|
4648
4654
|
if (phxChildrenAdded) {
|
|
4649
4655
|
this.joinNewChildren();
|
|
4650
4656
|
}
|
|
4657
|
+
return true;
|
|
4651
4658
|
}
|
|
4652
4659
|
renderContainer(diff, kind) {
|
|
4653
4660
|
return this.liveSocket.time(`toString diff (${kind})`, () => {
|
|
@@ -4726,11 +4733,9 @@ var View = class _View {
|
|
|
4726
4733
|
delete this.viewHooks[hookId];
|
|
4727
4734
|
}
|
|
4728
4735
|
applyPendingUpdates() {
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
this.pendingDiffs.forEach(({ diff, events }) => this.update(diff, events));
|
|
4733
|
-
this.pendingDiffs = [];
|
|
4736
|
+
this.pendingDiffs = this.pendingDiffs.filter(
|
|
4737
|
+
({ diff, events }) => !this.update(diff, events, true)
|
|
4738
|
+
);
|
|
4734
4739
|
this.eachChild((child) => child.applyPendingUpdates());
|
|
4735
4740
|
}
|
|
4736
4741
|
eachChild(callback) {
|
|
@@ -5785,7 +5790,7 @@ var LiveSocket = class {
|
|
|
5785
5790
|
}
|
|
5786
5791
|
// public
|
|
5787
5792
|
version() {
|
|
5788
|
-
return "1.1.
|
|
5793
|
+
return "1.1.8";
|
|
5789
5794
|
}
|
|
5790
5795
|
isProfileEnabled() {
|
|
5791
5796
|
return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";
|