@aevantec/litevue 0.6.1 → 0.6.2
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/litevue-devtools.iife.js +1 -1
- package/dist/litevue-devtools.mjs +1 -1
- package/dist/litevue-devtools.umd.js +1 -1
- package/dist/litevue-plugins.dev.iife.js +64 -41
- package/dist/litevue-plugins.dev.mjs +64 -40
- package/dist/litevue-plugins.iife.js +1 -1
- package/dist/litevue-plugins.mjs +1 -1
- package/dist/litevue-plugins.umd.js +1 -1
- package/dist/litevue.dev.iife.js +121 -39
- package/dist/litevue.dev.mjs +121 -38
- package/dist/litevue.iife.js +1 -1
- package/dist/litevue.mjs +1 -1
- package/dist/litevue.umd.js +1 -1
- package/dist/plugins/collapse.iife.js +1 -1
- package/dist/plugins/collapse.mjs +1 -1
- package/dist/plugins/collapse.umd.js +1 -1
- package/dist/plugins/focus.iife.js +1 -1
- package/dist/plugins/focus.mjs +1 -1
- package/dist/plugins/focus.umd.js +1 -1
- package/dist/plugins/intersect.iife.js +1 -1
- package/dist/plugins/intersect.umd.js +1 -1
- package/dist/plugins/mask.iife.js +1 -1
- package/dist/plugins/mask.mjs +1 -1
- package/dist/plugins/mask.umd.js +1 -1
- package/dist/plugins/media.dev.iife.js +3 -4
- package/dist/plugins/media.dev.mjs +3 -3
- package/dist/plugins/media.iife.js +1 -1
- package/dist/plugins/media.mjs +1 -1
- package/dist/plugins/media.umd.js +1 -1
- package/dist/plugins/morph.dev.iife.js +39 -19
- package/dist/plugins/morph.dev.mjs +39 -18
- package/dist/plugins/morph.iife.js +1 -1
- package/dist/plugins/morph.mjs +1 -1
- package/dist/plugins/morph.umd.js +1 -1
- package/dist/plugins/navigate.dev.iife.js +26 -19
- package/dist/plugins/navigate.dev.mjs +26 -18
- package/dist/plugins/navigate.iife.js +1 -1
- package/dist/plugins/navigate.mjs +1 -1
- package/dist/plugins/navigate.umd.js +1 -1
- package/dist/plugins/persist.dev.iife.js +2 -3
- package/dist/plugins/persist.dev.mjs +2 -2
- package/dist/plugins/persist.iife.js +1 -1
- package/dist/plugins/persist.mjs +1 -1
- package/dist/plugins/persist.umd.js +1 -1
- package/dist/plugins/popover.iife.js +1 -1
- package/dist/plugins/popover.mjs +1 -1
- package/dist/plugins/popover.umd.js +1 -1
- package/dist/plugins/resize.iife.js +1 -1
- package/dist/plugins/resize.umd.js +1 -1
- package/dist/plugins/transition.iife.js +1 -1
- package/dist/plugins/transition.mjs +1 -1
- package/dist/plugins/transition.umd.js +1 -1
- package/dist/types/app.d.mts +3 -1
- package/dist/types/app.d.ts +3 -1
- package/dist/types/context.d.mts +1 -1
- package/dist/types/context.d.ts +1 -1
- package/dist/types/devtools-panel/chrome.d.mts +6 -5
- package/dist/types/devtools-panel/chrome.d.ts +6 -5
- package/dist/types/devtools-panel/menu.d.mts +12 -0
- package/dist/types/devtools-panel/menu.d.ts +12 -0
- package/dist/types/devtools-panel/styles.d.mts +5 -2
- package/dist/types/devtools-panel/styles.d.ts +5 -2
- package/dist/types/devtools-panel/values.d.mts +11 -5
- package/dist/types/devtools-panel/values.d.ts +11 -5
- package/dist/types/directives/show.d.mts +1 -0
- package/dist/types/directives/show.d.ts +1 -0
- package/dist/types/errors.d.mts +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/store.d.mts +5 -1
- package/dist/types/store.d.ts +5 -1
- package/package.json +3 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var LiteVueMorph = (function(exports) {
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
// src/plugins/morph/index.ts
|
|
4
3
|
/**
|
|
5
4
|
* A `data-` attribute rather than `v-preserve`: an unrecognised `v-` attribute
|
|
@@ -7,6 +6,7 @@ var LiteVueMorph = (function(exports) {
|
|
|
7
6
|
* strip it, leaving nothing for the next morph. Matches `data-morph-skip`.
|
|
8
7
|
*/
|
|
9
8
|
var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || node.__marker || !!opts.preserve?.(node));
|
|
9
|
+
var LAZY = "[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]";
|
|
10
10
|
var dirRE = /^(?:v-|:|@)/;
|
|
11
11
|
var bindRE = /^(?::|v-bind:)/;
|
|
12
12
|
var clientStyleRE = /^v-(?!scope|on:)/;
|
|
@@ -51,12 +51,17 @@ var LiteVueMorph = (function(exports) {
|
|
|
51
51
|
var boundAttrs = (to) => {
|
|
52
52
|
const owned = /* @__PURE__ */ new Set();
|
|
53
53
|
if (to.matches("details,dialog")) owned.add("open");
|
|
54
|
-
for (const { name } of to.attributes) if (bindRE.test(name))
|
|
55
|
-
|
|
54
|
+
for (const { name } of to.attributes) if (bindRE.test(name)) {
|
|
55
|
+
const attr = name.replace(bindRE, "").split(".")[0];
|
|
56
|
+
owned.add(/\.camel\b/.test(name) ? attr.replace(/-(\w)/g, (_, c) => c.toUpperCase()) : attr);
|
|
57
|
+
} else if (/^v-model\b/.test(name)) {
|
|
56
58
|
owned.add("value");
|
|
57
59
|
owned.add("checked");
|
|
58
60
|
} else if (name === "v-bind") owned.add("*");
|
|
59
|
-
else if (clientStyleRE.test(name))
|
|
61
|
+
else if (clientStyleRE.test(name)) {
|
|
62
|
+
owned.add("style");
|
|
63
|
+
name == "v-popover" && owned.add("popover");
|
|
64
|
+
}
|
|
60
65
|
return owned;
|
|
61
66
|
};
|
|
62
67
|
/**
|
|
@@ -78,15 +83,17 @@ var LiteVueMorph = (function(exports) {
|
|
|
78
83
|
];
|
|
79
84
|
var syncValues = (from, to, owned) => {
|
|
80
85
|
const ctl = boundAttrs(to.closest("select") || to);
|
|
81
|
-
if (owned.has("*") || ctl.has("*") || ctl.has("value")) return;
|
|
86
|
+
if (owned.has("*") || ctl.has("*") || ctl.has("value") || from.type == "output" || from.type == "textarea" && to.value.includes("{{")) return;
|
|
82
87
|
for (const name of FIELD_PROPS) {
|
|
83
88
|
const prop = name.toLowerCase();
|
|
84
89
|
const init = "default" + name;
|
|
85
|
-
|
|
90
|
+
const src = name == "Selected" ? init : prop;
|
|
91
|
+
if (!owned.has(prop) && init in from && from[prop] !== to[src]) from[prop] = to[src];
|
|
86
92
|
}
|
|
87
93
|
};
|
|
88
94
|
var patchAttrs = (from, to, values) => {
|
|
89
95
|
const owned = boundAttrs(to);
|
|
96
|
+
if (from.__anchor) owned.add("style");
|
|
90
97
|
if (values) syncValues(from, to, owned);
|
|
91
98
|
const bound = Object(from.__bound);
|
|
92
99
|
for (const { name, value } of to.attributes) {
|
|
@@ -107,7 +114,7 @@ var LiteVueMorph = (function(exports) {
|
|
|
107
114
|
if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx, opts);
|
|
108
115
|
if (from.nodeType === 3 || from.nodeType === 8) {
|
|
109
116
|
const data = to.data;
|
|
110
|
-
if (isInterpolation(data, ctx)) return;
|
|
117
|
+
if (isInterpolation(data, ctx) && from.parentNode?.nodeName != "SCRIPT") return;
|
|
111
118
|
if (!from.data) return replaceNode(from, to, ctx, opts);
|
|
112
119
|
if (from.data !== data) from.data = data;
|
|
113
120
|
return;
|
|
@@ -117,9 +124,10 @@ var LiteVueMorph = (function(exports) {
|
|
|
117
124
|
const b = to;
|
|
118
125
|
if (a.tagName !== b.tagName) return replaceNode(from, to, ctx, opts);
|
|
119
126
|
if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
|
|
127
|
+
if (a.matches(LAZY)) return a.isEqualNode(b) ? void 0 : replaceNode(from, to, ctx, opts);
|
|
120
128
|
patchAttrs(a, b, opts.values);
|
|
121
|
-
if (a.tagName == "TEMPLATE") a.innerHTML = b.innerHTML;
|
|
122
|
-
if (!ownsChildren(b) && !a.__ctx?.scope
|
|
129
|
+
if (a.tagName == "TEMPLATE" && !a.content.isEqualNode(b.content)) a.innerHTML = b.innerHTML;
|
|
130
|
+
if (!ownsChildren(b) && !Object.getOwnPropertyDescriptor(Object(a.__ctx?.scope), "$template")) patchChildren(a, b, a.__ctx || ctx, opts);
|
|
123
131
|
};
|
|
124
132
|
var replaceNode = (from, to, ctx, opts) => {
|
|
125
133
|
if (preserved(from, opts)) return;
|
|
@@ -129,6 +137,7 @@ var LiteVueMorph = (function(exports) {
|
|
|
129
137
|
from.parentNode.replaceChild(fresh, from);
|
|
130
138
|
opts.afterNodeRemoved?.(from);
|
|
131
139
|
mountNew(fresh, ctx);
|
|
140
|
+
return fresh;
|
|
132
141
|
};
|
|
133
142
|
/**
|
|
134
143
|
* Bind never-walked markup with the scope it was inserted into. The walker
|
|
@@ -136,7 +145,7 @@ var LiteVueMorph = (function(exports) {
|
|
|
136
145
|
* copy of the core into the plugins bundle.
|
|
137
146
|
*/
|
|
138
147
|
var mountNew = (node, ctx) => {
|
|
139
|
-
if (node.parentElement?.closest(
|
|
148
|
+
if (node.parentElement?.closest(LAZY)) return;
|
|
140
149
|
const target = ctx || nearestCtx(node.parentNode);
|
|
141
150
|
target?.walk?.(node, target);
|
|
142
151
|
};
|
|
@@ -150,6 +159,15 @@ var LiteVueMorph = (function(exports) {
|
|
|
150
159
|
keyed.set(k, n);
|
|
151
160
|
}
|
|
152
161
|
const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
|
|
162
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
163
|
+
for (let n = to.firstChild; n; n = n.nextSibling) wanted.add(keyOf(n));
|
|
164
|
+
const drop = (node) => {
|
|
165
|
+
if (!preserved(node, opts)) {
|
|
166
|
+
release(node, ctx);
|
|
167
|
+
from.removeChild(node);
|
|
168
|
+
opts.afterNodeRemoved?.(node);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
153
171
|
let oldChild = from.firstChild;
|
|
154
172
|
let newChild = to.firstChild;
|
|
155
173
|
const insert = (node) => {
|
|
@@ -178,16 +196,17 @@ var LiteVueMorph = (function(exports) {
|
|
|
178
196
|
const nextOld = oldChild.nextSibling;
|
|
179
197
|
patchNode(oldChild, newChild, ctx, opts);
|
|
180
198
|
oldChild = nextOld;
|
|
199
|
+
} else if (oldChild && !wanted.has(keyOf(oldChild))) {
|
|
200
|
+
const nextOld = oldChild.nextSibling;
|
|
201
|
+
drop(oldChild);
|
|
202
|
+
oldChild = nextOld;
|
|
203
|
+
continue;
|
|
181
204
|
} else insert(newChild);
|
|
182
205
|
newChild = nextNew;
|
|
183
206
|
}
|
|
184
207
|
while (oldChild) {
|
|
185
208
|
const next = oldChild.nextSibling;
|
|
186
|
-
|
|
187
|
-
release(oldChild, ctx);
|
|
188
|
-
from.removeChild(oldChild);
|
|
189
|
-
opts.afterNodeRemoved?.(oldChild);
|
|
190
|
-
}
|
|
209
|
+
drop(oldChild);
|
|
191
210
|
oldChild = next;
|
|
192
211
|
}
|
|
193
212
|
};
|
|
@@ -199,18 +218,19 @@ var LiteVueMorph = (function(exports) {
|
|
|
199
218
|
let target;
|
|
200
219
|
if (typeof to === "string") {
|
|
201
220
|
const holder = document.createElement("template");
|
|
202
|
-
|
|
203
|
-
|
|
221
|
+
const svg = from instanceof SVGElement;
|
|
222
|
+
holder.innerHTML = svg ? `<svg>${to.trim()}</svg>` : to.trim();
|
|
223
|
+
const content = svg ? holder.content.firstChild : holder.content;
|
|
204
224
|
target = content.childNodes.length === 1 && content.firstElementChild ? content.firstElementChild : (() => {
|
|
205
225
|
const wrapper = from.cloneNode(false);
|
|
206
|
-
wrapper.
|
|
226
|
+
wrapper.append(...content.childNodes);
|
|
207
227
|
return wrapper;
|
|
208
228
|
})();
|
|
209
229
|
} else target = to;
|
|
210
230
|
if (target) {
|
|
211
231
|
const patch = () => {
|
|
212
232
|
const restore = captureFocus();
|
|
213
|
-
patchNode(from, target, nearestCtx(from), opts);
|
|
233
|
+
from = patchNode(from, target, nearestCtx(from.parentNode), opts) || from;
|
|
214
234
|
restore();
|
|
215
235
|
};
|
|
216
236
|
opts.transition && document.startViewTransition ? document.startViewTransition(patch) : patch();
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* strip it, leaving nothing for the next morph. Matches `data-morph-skip`.
|
|
6
6
|
*/
|
|
7
7
|
var preserved = (node, opts) => node.nodeType === 1 && (node.hasAttribute("data-morph-preserve") || node.__marker || !!opts.preserve?.(node));
|
|
8
|
+
var LAZY = "[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]";
|
|
8
9
|
var dirRE = /^(?:v-|:|@)/;
|
|
9
10
|
var bindRE = /^(?::|v-bind:)/;
|
|
10
11
|
var clientStyleRE = /^v-(?!scope|on:)/;
|
|
@@ -49,12 +50,17 @@ var release = (node, ctx) => (ctx || ctxIn(node))?.dispose?.(node);
|
|
|
49
50
|
var boundAttrs = (to) => {
|
|
50
51
|
const owned = /* @__PURE__ */ new Set();
|
|
51
52
|
if (to.matches("details,dialog")) owned.add("open");
|
|
52
|
-
for (const { name } of to.attributes) if (bindRE.test(name))
|
|
53
|
-
|
|
53
|
+
for (const { name } of to.attributes) if (bindRE.test(name)) {
|
|
54
|
+
const attr = name.replace(bindRE, "").split(".")[0];
|
|
55
|
+
owned.add(/\.camel\b/.test(name) ? attr.replace(/-(\w)/g, (_, c) => c.toUpperCase()) : attr);
|
|
56
|
+
} else if (/^v-model\b/.test(name)) {
|
|
54
57
|
owned.add("value");
|
|
55
58
|
owned.add("checked");
|
|
56
59
|
} else if (name === "v-bind") owned.add("*");
|
|
57
|
-
else if (clientStyleRE.test(name))
|
|
60
|
+
else if (clientStyleRE.test(name)) {
|
|
61
|
+
owned.add("style");
|
|
62
|
+
name == "v-popover" && owned.add("popover");
|
|
63
|
+
}
|
|
58
64
|
return owned;
|
|
59
65
|
};
|
|
60
66
|
/**
|
|
@@ -76,15 +82,17 @@ var FIELD_PROPS = [
|
|
|
76
82
|
];
|
|
77
83
|
var syncValues = (from, to, owned) => {
|
|
78
84
|
const ctl = boundAttrs(to.closest("select") || to);
|
|
79
|
-
if (owned.has("*") || ctl.has("*") || ctl.has("value")) return;
|
|
85
|
+
if (owned.has("*") || ctl.has("*") || ctl.has("value") || from.type == "output" || from.type == "textarea" && to.value.includes("{{")) return;
|
|
80
86
|
for (const name of FIELD_PROPS) {
|
|
81
87
|
const prop = name.toLowerCase();
|
|
82
88
|
const init = "default" + name;
|
|
83
|
-
|
|
89
|
+
const src = name == "Selected" ? init : prop;
|
|
90
|
+
if (!owned.has(prop) && init in from && from[prop] !== to[src]) from[prop] = to[src];
|
|
84
91
|
}
|
|
85
92
|
};
|
|
86
93
|
var patchAttrs = (from, to, values) => {
|
|
87
94
|
const owned = boundAttrs(to);
|
|
95
|
+
if (from.__anchor) owned.add("style");
|
|
88
96
|
if (values) syncValues(from, to, owned);
|
|
89
97
|
const bound = Object(from.__bound);
|
|
90
98
|
for (const { name, value } of to.attributes) {
|
|
@@ -105,7 +113,7 @@ var patchNode = (from, to, ctx, opts) => {
|
|
|
105
113
|
if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx, opts);
|
|
106
114
|
if (from.nodeType === 3 || from.nodeType === 8) {
|
|
107
115
|
const data = to.data;
|
|
108
|
-
if (isInterpolation(data, ctx)) return;
|
|
116
|
+
if (isInterpolation(data, ctx) && from.parentNode?.nodeName != "SCRIPT") return;
|
|
109
117
|
if (!from.data) return replaceNode(from, to, ctx, opts);
|
|
110
118
|
if (from.data !== data) from.data = data;
|
|
111
119
|
return;
|
|
@@ -115,9 +123,10 @@ var patchNode = (from, to, ctx, opts) => {
|
|
|
115
123
|
const b = to;
|
|
116
124
|
if (a.tagName !== b.tagName) return replaceNode(from, to, ctx, opts);
|
|
117
125
|
if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
|
|
126
|
+
if (a.matches(LAZY)) return a.isEqualNode(b) ? void 0 : replaceNode(from, to, ctx, opts);
|
|
118
127
|
patchAttrs(a, b, opts.values);
|
|
119
|
-
if (a.tagName == "TEMPLATE") a.innerHTML = b.innerHTML;
|
|
120
|
-
if (!ownsChildren(b) && !a.__ctx?.scope
|
|
128
|
+
if (a.tagName == "TEMPLATE" && !a.content.isEqualNode(b.content)) a.innerHTML = b.innerHTML;
|
|
129
|
+
if (!ownsChildren(b) && !Object.getOwnPropertyDescriptor(Object(a.__ctx?.scope), "$template")) patchChildren(a, b, a.__ctx || ctx, opts);
|
|
121
130
|
};
|
|
122
131
|
var replaceNode = (from, to, ctx, opts) => {
|
|
123
132
|
if (preserved(from, opts)) return;
|
|
@@ -127,6 +136,7 @@ var replaceNode = (from, to, ctx, opts) => {
|
|
|
127
136
|
from.parentNode.replaceChild(fresh, from);
|
|
128
137
|
opts.afterNodeRemoved?.(from);
|
|
129
138
|
mountNew(fresh, ctx);
|
|
139
|
+
return fresh;
|
|
130
140
|
};
|
|
131
141
|
/**
|
|
132
142
|
* Bind never-walked markup with the scope it was inserted into. The walker
|
|
@@ -134,7 +144,7 @@ var replaceNode = (from, to, ctx, opts) => {
|
|
|
134
144
|
* copy of the core into the plugins bundle.
|
|
135
145
|
*/
|
|
136
146
|
var mountNew = (node, ctx) => {
|
|
137
|
-
if (node.parentElement?.closest(
|
|
147
|
+
if (node.parentElement?.closest(LAZY)) return;
|
|
138
148
|
const target = ctx || nearestCtx(node.parentNode);
|
|
139
149
|
target?.walk?.(node, target);
|
|
140
150
|
};
|
|
@@ -148,6 +158,15 @@ var patchChildren = (from, to, ctx, opts) => {
|
|
|
148
158
|
keyed.set(k, n);
|
|
149
159
|
}
|
|
150
160
|
const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
|
|
161
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
162
|
+
for (let n = to.firstChild; n; n = n.nextSibling) wanted.add(keyOf(n));
|
|
163
|
+
const drop = (node) => {
|
|
164
|
+
if (!preserved(node, opts)) {
|
|
165
|
+
release(node, ctx);
|
|
166
|
+
from.removeChild(node);
|
|
167
|
+
opts.afterNodeRemoved?.(node);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
151
170
|
let oldChild = from.firstChild;
|
|
152
171
|
let newChild = to.firstChild;
|
|
153
172
|
const insert = (node) => {
|
|
@@ -176,16 +195,17 @@ var patchChildren = (from, to, ctx, opts) => {
|
|
|
176
195
|
const nextOld = oldChild.nextSibling;
|
|
177
196
|
patchNode(oldChild, newChild, ctx, opts);
|
|
178
197
|
oldChild = nextOld;
|
|
198
|
+
} else if (oldChild && !wanted.has(keyOf(oldChild))) {
|
|
199
|
+
const nextOld = oldChild.nextSibling;
|
|
200
|
+
drop(oldChild);
|
|
201
|
+
oldChild = nextOld;
|
|
202
|
+
continue;
|
|
179
203
|
} else insert(newChild);
|
|
180
204
|
newChild = nextNew;
|
|
181
205
|
}
|
|
182
206
|
while (oldChild) {
|
|
183
207
|
const next = oldChild.nextSibling;
|
|
184
|
-
|
|
185
|
-
release(oldChild, ctx);
|
|
186
|
-
from.removeChild(oldChild);
|
|
187
|
-
opts.afterNodeRemoved?.(oldChild);
|
|
188
|
-
}
|
|
208
|
+
drop(oldChild);
|
|
189
209
|
oldChild = next;
|
|
190
210
|
}
|
|
191
211
|
};
|
|
@@ -197,18 +217,19 @@ var morph = (from, to, opts = {}) => {
|
|
|
197
217
|
let target;
|
|
198
218
|
if (typeof to === "string") {
|
|
199
219
|
const holder = document.createElement("template");
|
|
200
|
-
|
|
201
|
-
|
|
220
|
+
const svg = from instanceof SVGElement;
|
|
221
|
+
holder.innerHTML = svg ? `<svg>${to.trim()}</svg>` : to.trim();
|
|
222
|
+
const content = svg ? holder.content.firstChild : holder.content;
|
|
202
223
|
target = content.childNodes.length === 1 && content.firstElementChild ? content.firstElementChild : (() => {
|
|
203
224
|
const wrapper = from.cloneNode(false);
|
|
204
|
-
wrapper.
|
|
225
|
+
wrapper.append(...content.childNodes);
|
|
205
226
|
return wrapper;
|
|
206
227
|
})();
|
|
207
228
|
} else target = to;
|
|
208
229
|
if (target) {
|
|
209
230
|
const patch = () => {
|
|
210
231
|
const restore = captureFocus();
|
|
211
|
-
patchNode(from, target, nearestCtx(from), opts);
|
|
232
|
+
from = patchNode(from, target, nearestCtx(from.parentNode), opts) || from;
|
|
212
233
|
restore();
|
|
213
234
|
};
|
|
214
235
|
opts.transition && document.startViewTransition ? document.startViewTransition(patch) : patch();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var LiteVueMorph=function(e){
|
|
1
|
+
var LiteVueMorph=function(e){var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),n="[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]",o=/^(?:v-|:|@)/,i=/^(?::|v-bind:)/,r=/^v-(?!scope|on:)/,s=["id","data-key","data-id"],a=e=>{for(const t of s){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},l=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},d=e=>e.__ctx||[...e.children||[]].map(d).find(Boolean),c=(e,t)=>(t||d(e))?.dispose?.(e),u=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)if(i.test(n)){const e=n.replace(i,"").split(".")[0];t.add(/\.camel\b/.test(n)?e.replace(/-(\w)/g,(e,t)=>t.toUpperCase()):e)}else/^v-model\b/.test(n)?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):r.test(n)&&(t.add("style"),"v-popover"==n&&t.add("popover"));return t},f=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),p=["Value","Checked","Selected"],h=(e,t,n)=>{const i=u(t);e.__anchor&&i.add("style"),n&&((e,t,n)=>{const o=u(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")||"output"==e.type||"textarea"==e.type&&t.value.includes("{{")))for(const i of p){const o=i.toLowerCase(),r="default"+i,s="Selected"==i?r:o;!n.has(o)&&r in e&&e[o]!==t[s]&&(e[o]=t[s])}})(e,t,i);const r=Object(e.__bound);for(const{name:s,value:a}of t.attributes)o.test(s)||i.has(s)||s in r||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:o}of[...e.attributes])i.has("*")||i.has(o)||t.hasAttribute(o)||e.removeAttribute(o)},m=(e,t,o,i)=>{if(e.nodeType!==t.nodeType)return b(e,t,o,i);if(3===e.nodeType||8===e.nodeType){const n=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(n,o)&&"SCRIPT"!=e.parentNode?.nodeName)return;return e.data?void(e.data!==n&&(e.data=n)):b(e,t,o,i)}if(1!==e.nodeType)return;const r=e,s=t;if(r.tagName!==s.tagName)return b(e,t,o,i);if(!i.skip?.(r,s)&&!r.hasAttribute("data-morph-skip")){if(r.matches(n))return r.isEqualNode(s)?void 0:b(e,t,o,i);h(r,s,i.values),"TEMPLATE"!=r.tagName||r.content.isEqualNode(s.content)||(r.innerHTML=s.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||f(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(f(t))return!0;return!1})(s)||Object.getOwnPropertyDescriptor(Object(r.__ctx?.scope),"$template")||g(r,s,r.__ctx||o,i)}},b=(e,n,o,i)=>{if(t(e,i))return;const r=n.cloneNode(!0);return!1!==i.beforeNodeAdded?.(r)?(c(e,o),e.parentNode.replaceChild(r,e),i.afterNodeRemoved?.(e),v(r,o),r):void 0},v=(e,t)=>{if(e.parentElement?.closest(n))return;const o=t||l(e.parentNode);o?.walk?.(e,o)},g=(e,n,o,i)=>{const r=i.key||a,s=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=r(t);if(null==e)continue;s.set(e,t)}const l=e=>e&&1===e.nodeType?r(e):null,d=new Set;for(let t=n.firstChild;t;t=t.nextSibling)d.add(l(t));const u=n=>{t(n,i)||(c(n,o),e.removeChild(n),i.afterNodeRemoved?.(n))};let f=e.firstChild,p=n.firstChild;const h=t=>{const n=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(e.insertBefore(n,f),v(n,o))};for(;p;){const n=p.nextSibling,r=l(p);if(""===f?.data&&p.hasAttribute?.("v-teleport"))f=f.nextSibling;else if(null!=r){const t=s.get(r);t?(t===f?f=f.nextSibling:e.insertBefore(t,f),s.delete(r),m(t,p,o,i)):h(p)}else if(f&&null==l(f)){if(t(f,i)&&!t(p,i)){f=f.nextSibling;continue}const e=f.nextSibling;m(f,p,o,i),f=e}else{if(f&&!d.has(l(f))){const e=f.nextSibling;u(f),f=e;continue}h(p)}p=n}for(;f;){const e=f.nextSibling;u(f),f=e}},y=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template"),i=e instanceof SVGElement;n.innerHTML=i?`<svg>${t.trim()}</svg>`:t.trim();const r=i?n.content.firstChild:n.content;o=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.append(...r.childNodes),t})()}else o=t;if(o){const t=()=>{const t=A();e=m(e,o,l(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},A=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}};return e.morph=y,e.morphPlugin=e=>{e.scope.$morph=y},e}({});
|
package/dist/plugins/morph.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),t=/^(?:v-|:|@)/,
|
|
1
|
+
var e=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),t="[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]",n=/^(?:v-|:|@)/,o=/^(?::|v-bind:)/,i=/^v-(?!scope|on:)/,r=["id","data-key","data-id"],s=e=>{for(const t of r){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},a=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},l=e=>e.__ctx||[...e.children||[]].map(l).find(Boolean),d=(e,t)=>(t||l(e))?.dispose?.(e),c=e=>{const t=/* @__PURE__ */new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)if(o.test(n)){const e=n.replace(o,"").split(".")[0];t.add(/\.camel\b/.test(n)?e.replace(/-(\w)/g,(e,t)=>t.toUpperCase()):e)}else/^v-model\b/.test(n)?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):i.test(n)&&(t.add("style"),"v-popover"==n&&t.add("popover"));return t},u=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),f=["Value","Checked","Selected"],p=(e,t,o)=>{const i=c(t);e.__anchor&&i.add("style"),o&&((e,t,n)=>{const o=c(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")||"output"==e.type||"textarea"==e.type&&t.value.includes("{{")))for(const i of f){const o=i.toLowerCase(),r="default"+i,s="Selected"==i?r:o;!n.has(o)&&r in e&&e[o]!==t[s]&&(e[o]=t[s])}})(e,t,i);const r=Object(e.__bound);for(const{name:s,value:a}of t.attributes)n.test(s)||i.has(s)||s in r||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:n}of[...e.attributes])i.has("*")||i.has(n)||t.hasAttribute(n)||e.removeAttribute(n)},h=(e,n,o,i)=>{if(e.nodeType!==n.nodeType)return m(e,n,o,i);if(3===e.nodeType||8===e.nodeType){const t=n.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(t,o)&&"SCRIPT"!=e.parentNode?.nodeName)return;return e.data?void(e.data!==t&&(e.data=t)):m(e,n,o,i)}if(1!==e.nodeType)return;const r=e,s=n;if(r.tagName!==s.tagName)return m(e,n,o,i);if(!i.skip?.(r,s)&&!r.hasAttribute("data-morph-skip")){if(r.matches(t))return r.isEqualNode(s)?void 0:m(e,n,o,i);p(r,s,i.values),"TEMPLATE"!=r.tagName||r.content.isEqualNode(s.content)||(r.innerHTML=s.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||u(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(u(t))return!0;return!1})(s)||Object.getOwnPropertyDescriptor(Object(r.__ctx?.scope),"$template")||v(r,s,r.__ctx||o,i)}},m=(t,n,o,i)=>{if(e(t,i))return;const r=n.cloneNode(!0);return!1!==i.beforeNodeAdded?.(r)?(d(t,o),t.parentNode.replaceChild(r,t),i.afterNodeRemoved?.(t),b(r,o),r):void 0},b=(e,n)=>{if(e.parentElement?.closest(t))return;const o=n||a(e.parentNode);o?.walk?.(e,o)},v=(t,n,o,i)=>{const r=i.key||s,a=/* @__PURE__ */new Map;for(let e=t.firstChild;e;e=e.nextSibling)if(1===e.nodeType){const t=r(e);if(null==t)continue;a.set(t,e)}const l=e=>e&&1===e.nodeType?r(e):null,c=/* @__PURE__ */new Set;for(let e=n.firstChild;e;e=e.nextSibling)c.add(l(e));const u=n=>{e(n,i)||(d(n,o),t.removeChild(n),i.afterNodeRemoved?.(n))};let f=t.firstChild,p=n.firstChild;const m=e=>{const n=e.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(t.insertBefore(n,f),b(n,o))};for(;p;){const n=p.nextSibling,r=l(p);if(""===f?.data&&p.hasAttribute?.("v-teleport"))f=f.nextSibling;else if(null!=r){const e=a.get(r);e?(e===f?f=f.nextSibling:t.insertBefore(e,f),a.delete(r),h(e,p,o,i)):m(p)}else if(f&&null==l(f)){if(e(f,i)&&!e(p,i)){f=f.nextSibling;continue}const t=f.nextSibling;h(f,p,o,i),f=t}else{if(f&&!c.has(l(f))){const e=f.nextSibling;u(f),f=e;continue}m(p)}p=n}for(;f;){const e=f.nextSibling;u(f),f=e}},g=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template"),i=e instanceof SVGElement;n.innerHTML=i?`<svg>${t.trim()}</svg>`:t.trim();const r=i?n.content.firstChild:n.content;o=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.append(...r.childNodes),t})()}else o=t;if(o){const t=()=>{const t=y();e=h(e,o,a(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},y=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}},A=e=>{e.scope.$morph=g};export{g as morph,A as morphPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueMorph={})}(this,function(e){
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVueMorph={})}(this,function(e){var t=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),n="[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]",o=/^(?:v-|:|@)/,i=/^(?::|v-bind:)/,r=/^v-(?!scope|on:)/,s=["id","data-key","data-id"],a=e=>{for(const t of s){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},l=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},d=e=>e.__ctx||[...e.children||[]].map(d).find(Boolean),c=(e,t)=>(t||d(e))?.dispose?.(e),u=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)if(i.test(n)){const e=n.replace(i,"").split(".")[0];t.add(/\.camel\b/.test(n)?e.replace(/-(\w)/g,(e,t)=>t.toUpperCase()):e)}else/^v-model\b/.test(n)?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):r.test(n)&&(t.add("style"),"v-popover"==n&&t.add("popover"));return t},f=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),p=["Value","Checked","Selected"],h=(e,t,n)=>{const i=u(t);e.__anchor&&i.add("style"),n&&((e,t,n)=>{const o=u(t.closest("select")||t);if(!(n.has("*")||o.has("*")||o.has("value")||"output"==e.type||"textarea"==e.type&&t.value.includes("{{")))for(const i of p){const o=i.toLowerCase(),r="default"+i,s="Selected"==i?r:o;!n.has(o)&&r in e&&e[o]!==t[s]&&(e[o]=t[s])}})(e,t,i);const r=Object(e.__bound);for(const{name:s,value:a}of t.attributes)o.test(s)||i.has(s)||s in r||e.getAttribute(s)!==a&&e.setAttribute(s,a);for(const{name:o}of[...e.attributes])i.has("*")||i.has(o)||t.hasAttribute(o)||e.removeAttribute(o)},m=(e,t,o,i)=>{if(e.nodeType!==t.nodeType)return b(e,t,o,i);if(3===e.nodeType||8===e.nodeType){const n=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(n,o)&&"SCRIPT"!=e.parentNode?.nodeName)return;return e.data?void(e.data!==n&&(e.data=n)):b(e,t,o,i)}if(1!==e.nodeType)return;const r=e,s=t;if(r.tagName!==s.tagName)return b(e,t,o,i);if(!i.skip?.(r,s)&&!r.hasAttribute("data-morph-skip")){if(r.matches(n))return r.isEqualNode(s)?void 0:b(e,t,o,i);h(r,s,i.values),"TEMPLATE"!=r.tagName||r.content.isEqualNode(s.content)||(r.innerHTML=s.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||f(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(f(t))return!0;return!1})(s)||Object.getOwnPropertyDescriptor(Object(r.__ctx?.scope),"$template")||g(r,s,r.__ctx||o,i)}},b=(e,n,o,i)=>{if(t(e,i))return;const r=n.cloneNode(!0);return!1!==i.beforeNodeAdded?.(r)?(c(e,o),e.parentNode.replaceChild(r,e),i.afterNodeRemoved?.(e),v(r,o),r):void 0},v=(e,t)=>{if(e.parentElement?.closest(n))return;const o=t||l(e.parentNode);o?.walk?.(e,o)},g=(e,n,o,i)=>{const r=i.key||a,s=new Map;for(let t=e.firstChild;t;t=t.nextSibling)if(1===t.nodeType){const e=r(t);if(null==e)continue;s.set(e,t)}const l=e=>e&&1===e.nodeType?r(e):null,d=new Set;for(let t=n.firstChild;t;t=t.nextSibling)d.add(l(t));const u=n=>{t(n,i)||(c(n,o),e.removeChild(n),i.afterNodeRemoved?.(n))};let f=e.firstChild,p=n.firstChild;const h=t=>{const n=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(n)&&(e.insertBefore(n,f),v(n,o))};for(;p;){const n=p.nextSibling,r=l(p);if(""===f?.data&&p.hasAttribute?.("v-teleport"))f=f.nextSibling;else if(null!=r){const t=s.get(r);t?(t===f?f=f.nextSibling:e.insertBefore(t,f),s.delete(r),m(t,p,o,i)):h(p)}else if(f&&null==l(f)){if(t(f,i)&&!t(p,i)){f=f.nextSibling;continue}const e=f.nextSibling;m(f,p,o,i),f=e}else{if(f&&!d.has(l(f))){const e=f.nextSibling;u(f),f=e;continue}h(p)}p=n}for(;f;){const e=f.nextSibling;u(f),f=e}},y=(e,t,n={})=>{let o;if("string"==typeof t){const n=document.createElement("template"),i=e instanceof SVGElement;n.innerHTML=i?`<svg>${t.trim()}</svg>`:t.trim();const r=i?n.content.firstChild:n.content;o=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.append(...r.childNodes),t})()}else o=t;if(o){const t=()=>{const t=x();e=m(e,o,l(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},x=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,o=null;try{n=t.selectionStart,o=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,o)}catch{}}};e.morph=y,e.morphPlugin=e=>{e.scope.$morph=y}});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var LiteVueNavigate = (function(exports) {
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
/** Selector matching every scope root, deferred or not. */
|
|
4
3
|
var SCOPE_SELECTOR = ["[v-scope]", ...[
|
|
5
4
|
"visible",
|
|
@@ -13,6 +12,13 @@ var LiteVueNavigate = (function(exports) {
|
|
|
13
12
|
var SCROLL_SAVE_DELAY = 150;
|
|
14
13
|
var isLocal = (url) => url.origin === location.origin;
|
|
15
14
|
var pathOf = (url) => url.pathname + url.search;
|
|
15
|
+
var decode = (s) => {
|
|
16
|
+
try {
|
|
17
|
+
return decodeURIComponent(s);
|
|
18
|
+
} catch {
|
|
19
|
+
return s;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
16
22
|
var optedOut = (el) => !!el.closest("[data-navigate=\"false\"]");
|
|
17
23
|
var encode = (data) => new URLSearchParams([...data].map(([k, v]) => [k, v.name ?? v]));
|
|
18
24
|
var saveScroll = () => history.replaceState({
|
|
@@ -34,18 +40,21 @@ var LiteVueNavigate = (function(exports) {
|
|
|
34
40
|
const sel = "link,style,meta";
|
|
35
41
|
const live = [...document.head.querySelectorAll(sel)];
|
|
36
42
|
const loads = [];
|
|
43
|
+
let at;
|
|
37
44
|
for (const el of doc.head.querySelectorAll(sel)) {
|
|
38
45
|
const i = live.findIndex((l) => l.isEqualNode(el));
|
|
39
46
|
if (i > -1) {
|
|
40
|
-
live.splice(i, 1);
|
|
47
|
+
[at] = live.splice(i, 1);
|
|
41
48
|
continue;
|
|
42
49
|
}
|
|
43
50
|
const fresh = document.importNode(el, true);
|
|
44
|
-
if (fresh.matches("link[rel=stylesheet][href]:not([disabled]
|
|
51
|
+
if (fresh.matches("link[rel=stylesheet][href]:not([disabled]):not([href=\"\"])")) loads.push(new Promise((r) => {
|
|
45
52
|
fresh.addEventListener("load", r);
|
|
46
53
|
fresh.addEventListener("error", r);
|
|
47
54
|
}));
|
|
48
|
-
|
|
55
|
+
if (at) at.after(fresh);
|
|
56
|
+
else document.head.prepend(fresh);
|
|
57
|
+
at = fresh;
|
|
49
58
|
}
|
|
50
59
|
await Promise.all(loads);
|
|
51
60
|
return () => live.forEach((el) => el.matches("[data-navigate-preserve]") || el.remove());
|
|
@@ -64,12 +73,11 @@ var LiteVueNavigate = (function(exports) {
|
|
|
64
73
|
return false;
|
|
65
74
|
};
|
|
66
75
|
/**
|
|
67
|
-
* Morph with the app's roots kept in step.
|
|
68
|
-
*
|
|
69
|
-
* page
|
|
76
|
+
* Morph with the app's roots kept in step. Morph releases the roots it
|
|
77
|
+
* removes; at page level there is no scope to bind what it adds, so roots
|
|
78
|
+
* the page adds are mounted here.
|
|
70
79
|
*/
|
|
71
80
|
var render = (app, patch, from, to, values) => {
|
|
72
|
-
const roots = [from, ...from.querySelectorAll("*")].filter((el) => el.__ctx && !hasCtxAbove(el.parentElement));
|
|
73
81
|
const added = [];
|
|
74
82
|
patch(from, to, {
|
|
75
83
|
values,
|
|
@@ -77,7 +85,6 @@ var LiteVueNavigate = (function(exports) {
|
|
|
77
85
|
node.nodeType === 1 && added.push(node);
|
|
78
86
|
}
|
|
79
87
|
});
|
|
80
|
-
roots.forEach((el) => el.isConnected || app.unmount(el));
|
|
81
88
|
added.forEach((el) => el.isConnected && !hasCtxAbove(el) && (el.matches(SCOPE_SELECTOR) || el.querySelector(SCOPE_SELECTOR)) && app.mount(el));
|
|
82
89
|
};
|
|
83
90
|
var navigate = (app, options = {}) => {
|
|
@@ -109,7 +116,8 @@ var LiteVueNavigate = (function(exports) {
|
|
|
109
116
|
render(app, app.scope.$morph, from, doc.querySelector(target), ok);
|
|
110
117
|
dropOld();
|
|
111
118
|
if (options.scroll !== false) {
|
|
112
|
-
const
|
|
119
|
+
const id = url.hash.slice(1);
|
|
120
|
+
const anchor = y == null && id && (document.getElementById(id) || document.getElementById(decode(id)));
|
|
113
121
|
anchor ? anchor.scrollIntoView() : scrollTo(0, y || 0);
|
|
114
122
|
}
|
|
115
123
|
if (ok) moveFocus(from);
|
|
@@ -138,7 +146,7 @@ var LiteVueNavigate = (function(exports) {
|
|
|
138
146
|
}));
|
|
139
147
|
const url = new URL(res.url || href);
|
|
140
148
|
url.hash ||= new URL(href).hash;
|
|
141
|
-
if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && !post) {
|
|
149
|
+
if (!res.headers.get("content-type")?.includes("text/html") || !isLocal(url) || !res.ok && (!post || res.redirected)) {
|
|
142
150
|
res.body?.cancel();
|
|
143
151
|
throw new Error(`cannot render ${res.status} from ${url.href}`);
|
|
144
152
|
}
|
|
@@ -148,21 +156,20 @@ var LiteVueNavigate = (function(exports) {
|
|
|
148
156
|
const from = document.querySelector(target);
|
|
149
157
|
if (!from || !doc.querySelector(target)) throw new Error(`no ${target} in ${url.href}`);
|
|
150
158
|
if (assets(doc) !== assets(document)) throw new Error(`${url.href} loads different scripts or styles`);
|
|
151
|
-
doc.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove());
|
|
159
|
+
[doc, from].forEach((d) => d.querySelectorAll("script,noscript").forEach((s) => /^\s*(module\s*)?$|script/i.test(s.type || "") && s.remove()));
|
|
152
160
|
const dropOld = await mergeHead(doc);
|
|
153
161
|
const ok = res.ok;
|
|
154
|
-
const run = () => c === controller && show(from, doc, url, ok, dropOld, y);
|
|
162
|
+
const run = () => c === controller && (setBusy([]), show(from, doc, url, ok, dropOld, y));
|
|
155
163
|
options.transition && document.startViewTransition ? document.startViewTransition(run) : run();
|
|
156
164
|
} catch (error) {
|
|
157
165
|
if (c.signal.aborted) return;
|
|
166
|
+
setBusy([]);
|
|
158
167
|
emit("error", {
|
|
159
168
|
url: href,
|
|
160
169
|
error
|
|
161
170
|
});
|
|
162
171
|
if (!post) location.assign(href);
|
|
163
172
|
else if (res?.redirected) location.assign(res.url);
|
|
164
|
-
} finally {
|
|
165
|
-
c === controller && setBusy([]);
|
|
166
173
|
}
|
|
167
174
|
};
|
|
168
175
|
/** The URL a link leads to, when navigate would take it over. */
|
|
@@ -176,9 +183,9 @@ var LiteVueNavigate = (function(exports) {
|
|
|
176
183
|
if (url.href.includes("#") && pathOf(url) === pathOf(location)) return;
|
|
177
184
|
return url;
|
|
178
185
|
};
|
|
186
|
+
const special = (e) => e.button || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
|
|
179
187
|
const onClick = (e) => {
|
|
180
|
-
if (e.defaultPrevented || e
|
|
181
|
-
if (e.shiftKey || e.altKey) return;
|
|
188
|
+
if (e.defaultPrevented || special(e)) return;
|
|
182
189
|
const url = linkTo(e);
|
|
183
190
|
if (!url) return;
|
|
184
191
|
e.preventDefault();
|
|
@@ -213,7 +220,7 @@ var LiteVueNavigate = (function(exports) {
|
|
|
213
220
|
["focusin", onHover],
|
|
214
221
|
["pointerout", onLeave],
|
|
215
222
|
["focusout", onLeave],
|
|
216
|
-
["pointerdown", prefetch]
|
|
223
|
+
["pointerdown", (e) => special(e) || prefetch(e)]
|
|
217
224
|
] : [];
|
|
218
225
|
const onSubmit = (e) => {
|
|
219
226
|
const form = e.target;
|
|
@@ -225,7 +232,7 @@ var LiteVueNavigate = (function(exports) {
|
|
|
225
232
|
if (e.defaultPrevented || method === "dialog" || optedOut(form)) return;
|
|
226
233
|
if (type === "text/plain") return;
|
|
227
234
|
if (where && where !== "_self") return;
|
|
228
|
-
const url = new URL(attr("action") || location.href,
|
|
235
|
+
const url = new URL(attr("action") || location.href, document.baseURI);
|
|
229
236
|
if (!isLocal(url)) return;
|
|
230
237
|
const data = new FormData(form);
|
|
231
238
|
if (by?.name) data.append(by.name, by.value);
|