unpoly-rails 3.11.0.rc1 → 3.11.0.rc12
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.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly-bootstrap3.js +1 -1
- data/assets/unpoly/unpoly-bootstrap3.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap4.js +1 -1
- data/assets/unpoly/unpoly-bootstrap4.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap5.js +1 -1
- data/assets/unpoly/unpoly-bootstrap5.min.js +1 -1
- data/assets/unpoly/unpoly-migrate.js +61 -41
- data/assets/unpoly/unpoly-migrate.min.js +1 -1
- data/assets/unpoly/unpoly.es6.js +382 -361
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +377 -353
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +2 -2
data/assets/unpoly/unpoly.es6.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/***/ (() => {
|
6
6
|
|
7
7
|
window.up = {
|
8
|
-
version: '3.11.0-
|
8
|
+
version: '3.11.0-rc12'
|
9
9
|
};
|
10
10
|
|
11
11
|
|
@@ -146,6 +146,9 @@ up.util = (function () {
|
|
146
146
|
function isNull(value) {
|
147
147
|
return value === null;
|
148
148
|
}
|
149
|
+
function isTruthy(value) {
|
150
|
+
return !!value;
|
151
|
+
}
|
149
152
|
function isUndefined(value) {
|
150
153
|
return value === undefined;
|
151
154
|
}
|
@@ -424,7 +427,7 @@ up.util = (function () {
|
|
424
427
|
const filtered = {};
|
425
428
|
for (let key in object) {
|
426
429
|
const value = object[key];
|
427
|
-
if (tester(value, key
|
430
|
+
if (tester(value, key)) {
|
428
431
|
filtered[key] = object[key];
|
429
432
|
}
|
430
433
|
}
|
@@ -527,34 +530,36 @@ up.util = (function () {
|
|
527
530
|
return Object.prototype.hasOwnProperty(k);
|
528
531
|
}
|
529
532
|
function isEqual(a, b) {
|
533
|
+
if (a === b) {
|
534
|
+
return true;
|
535
|
+
}
|
530
536
|
if (a === null || a === void 0 ? void 0 : a.valueOf) {
|
531
537
|
a = a.valueOf();
|
532
538
|
}
|
533
539
|
if (b === null || b === void 0 ? void 0 : b.valueOf) {
|
534
540
|
b = b.valueOf();
|
535
541
|
}
|
542
|
+
if (a === b) {
|
543
|
+
return true;
|
544
|
+
}
|
536
545
|
if (typeof (a) !== typeof (b)) {
|
537
546
|
return false;
|
538
547
|
}
|
539
|
-
|
548
|
+
if (isList(a) && isList(b)) {
|
540
549
|
return isEqualList(a, b);
|
541
550
|
}
|
542
|
-
|
551
|
+
if (isObject(a) && a[isEqual.key]) {
|
543
552
|
return a[isEqual.key](b);
|
544
553
|
}
|
545
|
-
|
546
|
-
|
547
|
-
const bKeys = Object.keys(b);
|
548
|
-
if (isEqualList(aKeys, bKeys)) {
|
549
|
-
return every(aKeys, (aKey) => isEqual(a[aKey], b[aKey]));
|
550
|
-
}
|
551
|
-
else {
|
552
|
-
return false;
|
553
|
-
}
|
554
|
-
}
|
555
|
-
else {
|
556
|
-
return a === b;
|
554
|
+
if (isOptions(a) && isOptions(b)) {
|
555
|
+
return isEqualOptions(a, b);
|
557
556
|
}
|
557
|
+
return false;
|
558
|
+
}
|
559
|
+
function isEqualOptions(a, b) {
|
560
|
+
const aKeys = Object.keys(a);
|
561
|
+
const bKeys = Object.keys(b);
|
562
|
+
return isEqualList(aKeys, bKeys) && every(aKeys, (key) => isEqual(a[key], b[key]));
|
558
563
|
}
|
559
564
|
isEqual.key = 'up.util.isEqual';
|
560
565
|
function isEqualList(a, b) {
|
@@ -795,36 +800,39 @@ up.util = (function () {
|
|
795
800
|
}
|
796
801
|
function maskPattern(str, patterns, { keepDelimiters = false } = {}) {
|
797
802
|
let maskCount = 0;
|
798
|
-
let maskPattern =
|
799
|
-
let
|
800
|
-
let replaceLayers =
|
801
|
-
let replace = (replacePattern) => {
|
803
|
+
let maskPattern = /§\d+/g;
|
804
|
+
let maskings = {};
|
805
|
+
let replaceLayers = [];
|
806
|
+
let replace = (replacePattern, allowRestoreTransform) => {
|
802
807
|
let didReplace = false;
|
803
808
|
str = str.replaceAll(replacePattern, function (match) {
|
804
809
|
didReplace = true;
|
805
|
-
let
|
806
|
-
let
|
810
|
+
let mask = '§' + (maskCount++);
|
811
|
+
let remain;
|
807
812
|
let masked;
|
808
813
|
if (keepDelimiters) {
|
809
814
|
let startDelimiter = match[0];
|
810
815
|
let endDelimiter = match.slice(-1);
|
811
816
|
masked = match.slice(1, -1);
|
812
|
-
|
817
|
+
remain = startDelimiter + mask + endDelimiter;
|
813
818
|
}
|
814
819
|
else {
|
815
820
|
masked = match;
|
816
|
-
|
821
|
+
remain = mask;
|
817
822
|
}
|
818
|
-
|
819
|
-
return
|
823
|
+
maskings[mask] = masked;
|
824
|
+
return remain;
|
820
825
|
});
|
821
826
|
if (didReplace)
|
822
|
-
replaceLayers
|
827
|
+
replaceLayers.unshift({ allowRestoreTransform });
|
823
828
|
};
|
824
|
-
|
829
|
+
replace(maskPattern, false);
|
830
|
+
for (let pattern of patterns)
|
831
|
+
replace(pattern, true);
|
825
832
|
let restore = (s, transform = identity) => {
|
826
|
-
for (let
|
827
|
-
|
833
|
+
for (let { allowRestoreTransform } of replaceLayers) {
|
834
|
+
let iterationTransform = allowRestoreTransform ? transform : identity;
|
835
|
+
s = s.replace(maskPattern, (match) => iterationTransform(assert(maskings[match], isString)));
|
828
836
|
}
|
829
837
|
return s;
|
830
838
|
};
|
@@ -838,6 +846,7 @@ up.util = (function () {
|
|
838
846
|
function ensureDoubleQuotes(str) {
|
839
847
|
if (str[0] === '"')
|
840
848
|
return str;
|
849
|
+
assert(str[0] === "'");
|
841
850
|
str = str.slice(1, -1);
|
842
851
|
let transformed = str.replace(/(\\\\)|(\\')|(\\")|(")/g, function (_match, escapedBackslash, escapedSingleQuote, _doubleQuote) {
|
843
852
|
return escapedBackslash
|
@@ -869,6 +878,14 @@ up.util = (function () {
|
|
869
878
|
function spanObject(keys, value) {
|
870
879
|
return mapObject(keys, (key) => [key, value]);
|
871
880
|
}
|
881
|
+
function assert(value, testFn = isTruthy) {
|
882
|
+
if (testFn(value)) {
|
883
|
+
return value;
|
884
|
+
}
|
885
|
+
else {
|
886
|
+
throw "assert failed";
|
887
|
+
}
|
888
|
+
}
|
872
889
|
return {
|
873
890
|
parseURL,
|
874
891
|
normalizeURL,
|
@@ -977,6 +994,7 @@ up.util = (function () {
|
|
977
994
|
maskPattern,
|
978
995
|
expressionOutline,
|
979
996
|
parseString,
|
997
|
+
assert,
|
980
998
|
};
|
981
999
|
})();
|
982
1000
|
|
@@ -1544,7 +1562,7 @@ up.element = (function () {
|
|
1544
1562
|
}
|
1545
1563
|
function extractFromStyleObject(style, keyOrKeys) {
|
1546
1564
|
if (up.migrate.loaded)
|
1547
|
-
keyOrKeys = up.migrate.
|
1565
|
+
keyOrKeys = up.migrate.fixGetStyleProps(keyOrKeys);
|
1548
1566
|
if (u.isString(keyOrKeys)) {
|
1549
1567
|
return style.getPropertyValue(keyOrKeys);
|
1550
1568
|
}
|
@@ -1554,7 +1572,7 @@ up.element = (function () {
|
|
1554
1572
|
}
|
1555
1573
|
function setInlineStyle(element, props, unit = '') {
|
1556
1574
|
if (up.migrate.loaded)
|
1557
|
-
props = up.migrate.
|
1575
|
+
props = up.migrate.fixSetStyleProps(props, unit);
|
1558
1576
|
if (u.isString(props)) {
|
1559
1577
|
element.setAttribute('style', props);
|
1560
1578
|
}
|
@@ -1630,18 +1648,6 @@ up.element = (function () {
|
|
1630
1648
|
return [element.parentElement, 'beforeend'];
|
1631
1649
|
}
|
1632
1650
|
}
|
1633
|
-
function moveBefore(parent, movedElement, referenceElement) {
|
1634
|
-
let fn = parent.moveBefore || parent.insertBefore;
|
1635
|
-
fn.call(parent, movedElement, referenceElement);
|
1636
|
-
}
|
1637
|
-
function preservingAppend(parent, newNode) {
|
1638
|
-
moveBefore(parent, newNode, null);
|
1639
|
-
}
|
1640
|
-
function preservingReplace(oldElement, newElement) {
|
1641
|
-
let parent = oldElement.parentElement;
|
1642
|
-
moveBefore(parent, newElement, oldElement);
|
1643
|
-
oldElement.remove();
|
1644
|
-
}
|
1645
1651
|
return {
|
1646
1652
|
subtree,
|
1647
1653
|
subtreeFirst,
|
@@ -1710,8 +1716,6 @@ up.element = (function () {
|
|
1710
1716
|
matchSelectorMap,
|
1711
1717
|
elementLikeMatches,
|
1712
1718
|
documentPosition,
|
1713
|
-
preservingAppend,
|
1714
|
-
preservingReplace,
|
1715
1719
|
};
|
1716
1720
|
})();
|
1717
1721
|
|
@@ -2192,8 +2196,8 @@ up.Change.Addition = class Addition extends up.Change {
|
|
2192
2196
|
_responseOptions() {
|
2193
2197
|
return { response: this._response };
|
2194
2198
|
}
|
2195
|
-
executeSteps(steps, responseDoc, noneOptions) {
|
2196
|
-
return new up.Change.UpdateSteps({ steps, noneOptions }).execute(responseDoc);
|
2199
|
+
executeSteps({ steps, responseDoc, noneOptions, passRenderOptions = this.options }) {
|
2200
|
+
return new up.Change.UpdateSteps({ steps, noneOptions, passRenderOptions }).execute(responseDoc);
|
2197
2201
|
}
|
2198
2202
|
};
|
2199
2203
|
|
@@ -2214,8 +2218,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
2214
2218
|
var _a;
|
2215
2219
|
const u = up.util;
|
2216
2220
|
up.RenderJob = (_a = class RenderJob {
|
2217
|
-
constructor(
|
2218
|
-
this.
|
2221
|
+
constructor(renderOptions) {
|
2222
|
+
this.renderOptions = renderOptions;
|
2219
2223
|
}
|
2220
2224
|
execute() {
|
2221
2225
|
this._rendered = this._executePromise();
|
@@ -2225,9 +2229,9 @@ up.RenderJob = (_a = class RenderJob {
|
|
2225
2229
|
return __awaiter(this, void 0, void 0, function* () {
|
2226
2230
|
try {
|
2227
2231
|
this._emitGuardEvent();
|
2228
|
-
this.
|
2229
|
-
up.browser.assertConfirmed(this.
|
2230
|
-
up.RenderOptions.assertContentGiven(this.
|
2232
|
+
this.renderOptions = up.RenderOptions.preprocess(this.renderOptions);
|
2233
|
+
up.browser.assertConfirmed(this.renderOptions);
|
2234
|
+
up.RenderOptions.assertContentGiven(this.renderOptions);
|
2231
2235
|
let result = yield this._getChange().execute();
|
2232
2236
|
this._handleResult(result);
|
2233
2237
|
return result;
|
@@ -2240,7 +2244,7 @@ up.RenderJob = (_a = class RenderJob {
|
|
2240
2244
|
}
|
2241
2245
|
_handleResult(result) {
|
2242
2246
|
if (result instanceof up.RenderResult) {
|
2243
|
-
let { onRendered, onFinished } = result.
|
2247
|
+
let { onRendered, onFinished } = result.renderOptions;
|
2244
2248
|
if (!result.none)
|
2245
2249
|
up.error.guard(() => onRendered === null || onRendered === void 0 ? void 0 : onRendered(result));
|
2246
2250
|
let guardedOnFinished = function (result) {
|
@@ -2253,7 +2257,7 @@ up.RenderJob = (_a = class RenderJob {
|
|
2253
2257
|
_handleError(error) {
|
2254
2258
|
let prefix = error instanceof up.Aborted ? 'Rendering was aborted' : 'Error while rendering';
|
2255
2259
|
up.puts('up.render()', `${prefix}: ${error.name}: ${error.message}`);
|
2256
|
-
up.error.guard(() => { var _b, _c; return (_c = (_b = this.
|
2260
|
+
up.error.guard(() => { var _b, _c; return (_c = (_b = this.renderOptions).onError) === null || _c === void 0 ? void 0 : _c.call(_b, error); });
|
2257
2261
|
}
|
2258
2262
|
get finished() {
|
2259
2263
|
return this._awaitFinished();
|
@@ -2276,7 +2280,7 @@ up.RenderJob = (_a = class RenderJob {
|
|
2276
2280
|
}
|
2277
2281
|
_getChange() {
|
2278
2282
|
let handleAbort = u.memoize((request) => this._handleAbortOption(request));
|
2279
|
-
let renderOptions = Object.assign(Object.assign({}, this.
|
2283
|
+
let renderOptions = Object.assign(Object.assign({}, this.renderOptions), { handleAbort });
|
2280
2284
|
if (renderOptions.url) {
|
2281
2285
|
return new up.Change.FromURL(renderOptions);
|
2282
2286
|
}
|
@@ -2288,16 +2292,16 @@ up.RenderJob = (_a = class RenderJob {
|
|
2288
2292
|
}
|
2289
2293
|
}
|
2290
2294
|
_emitGuardEvent() {
|
2291
|
-
let guardEvent = u.pluckKey(this.
|
2295
|
+
let guardEvent = u.pluckKey(this.renderOptions, 'guardEvent');
|
2292
2296
|
if (guardEvent) {
|
2293
|
-
guardEvent.renderOptions = this.
|
2294
|
-
if (up.emit(guardEvent, { target: this.
|
2297
|
+
guardEvent.renderOptions = this.renderOptions;
|
2298
|
+
if (up.emit(guardEvent, { target: this.renderOptions.origin }).defaultPrevented) {
|
2295
2299
|
throw new up.Aborted(`Rendering was prevented by ${guardEvent.type} listener`);
|
2296
2300
|
}
|
2297
2301
|
}
|
2298
2302
|
}
|
2299
2303
|
_handleAbortOption(request) {
|
2300
|
-
let { abort } = this.
|
2304
|
+
let { abort } = this.renderOptions;
|
2301
2305
|
if (!abort || !up.network.isBusy())
|
2302
2306
|
return;
|
2303
2307
|
let { bindFragments, bindLayer, origin, layer } = this._getChange().getPreflightProps();
|
@@ -2462,6 +2466,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2462
2466
|
this._assertOpenEventEmitted();
|
2463
2467
|
this.layer = this._buildLayer();
|
2464
2468
|
this._baseLayer.peel({ history: !this.layer.history });
|
2469
|
+
this._baseLayer.saveHistory();
|
2465
2470
|
up.layer.stack.push(this.layer);
|
2466
2471
|
this.layer.createElements();
|
2467
2472
|
this.layer.setupHandlers();
|
@@ -2471,14 +2476,15 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2471
2476
|
this.handleLayerChangeRequests();
|
2472
2477
|
this.responseDoc.commitElement(this._content);
|
2473
2478
|
this.layer.setContent(this._content);
|
2474
|
-
this.setReloadAttrs({ newElement: this._content, source: this.options.source });
|
2475
2479
|
this.responseDoc.finalizeElement(this._content);
|
2480
|
+
this.setReloadAttrs({ newElement: this._content, source: this.options.source });
|
2481
|
+
up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer, dataRoot: this._content }));
|
2476
2482
|
this._newOverlayResult = new up.RenderResult({
|
2477
2483
|
layer: this.layer,
|
2478
2484
|
fragments: [this._content],
|
2479
2485
|
target: this.target,
|
2486
|
+
renderOptions: this.options,
|
2480
2487
|
});
|
2481
|
-
up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer, dataRoot: this._content }));
|
2482
2488
|
this._handleScroll();
|
2483
2489
|
this._newOverlayResult.finished = this._finish();
|
2484
2490
|
this.layer.opening = false;
|
@@ -2489,7 +2495,10 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2489
2495
|
if (this._otherLayersResult)
|
2490
2496
|
return;
|
2491
2497
|
let otherLayerSteps = this._getHungrySteps().other;
|
2492
|
-
this._otherLayersResult = this.executeSteps(
|
2498
|
+
this._otherLayersResult = this.executeSteps({
|
2499
|
+
steps: otherLayerSteps,
|
2500
|
+
responseDoc: this.responseDoc,
|
2501
|
+
});
|
2493
2502
|
}
|
2494
2503
|
_finish() {
|
2495
2504
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -2511,9 +2520,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2511
2520
|
if (this.layer.history === 'auto') {
|
2512
2521
|
this.layer.history = up.fragment.hasAutoHistory([this._content], this.layer);
|
2513
2522
|
}
|
2514
|
-
|
2515
|
-
(_a = this.layer).history && (_a.history = parent.history);
|
2516
|
-
parent.saveHistory();
|
2523
|
+
(_a = this.layer).history && (_a.history = this._baseLayer.history);
|
2517
2524
|
this.layer.updateHistory(this.options);
|
2518
2525
|
}
|
2519
2526
|
_handleFocus() {
|
@@ -2630,13 +2637,20 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
|
|
2630
2637
|
this.layer.updateHistory(this.options);
|
2631
2638
|
}
|
2632
2639
|
this.handleLayerChangeRequests();
|
2633
|
-
this._currentLayerResult = this.executeSteps(
|
2640
|
+
this._currentLayerResult = this.executeSteps({
|
2641
|
+
steps: this._steps,
|
2642
|
+
responseDoc: this.responseDoc,
|
2643
|
+
noneOptions: this.options,
|
2644
|
+
});
|
2634
2645
|
}
|
2635
2646
|
_renderOtherLayers() {
|
2636
2647
|
if (this._otherLayersResult)
|
2637
2648
|
return;
|
2638
2649
|
let otherLayerSteps = this._getHungrySteps().other;
|
2639
|
-
this._otherLayersResult = this.executeSteps(
|
2650
|
+
this._otherLayersResult = this.executeSteps({
|
2651
|
+
steps: otherLayerSteps,
|
2652
|
+
responseDoc: this.responseDoc,
|
2653
|
+
});
|
2640
2654
|
}
|
2641
2655
|
_matchPreflight() {
|
2642
2656
|
this._matchOldElements();
|
@@ -2722,31 +2736,30 @@ const e = up.element;
|
|
2722
2736
|
up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
2723
2737
|
constructor(options) {
|
2724
2738
|
super(options);
|
2739
|
+
this._steps = u.copy(u.assert(options.steps));
|
2740
|
+
this._passRenderOptions = u.assert(options.passRenderOptions);
|
2725
2741
|
this._noneOptions = options.noneOptions || {};
|
2726
|
-
this._steps = u.copy(options.steps);
|
2727
2742
|
}
|
2728
2743
|
execute(responseDoc) {
|
2729
|
-
var _a;
|
2730
2744
|
this.responseDoc = responseDoc;
|
2731
2745
|
this._steps = responseDoc.selectSteps(this._steps);
|
2732
2746
|
this._steps = responseDoc.commitSteps(this._steps);
|
2733
|
-
if (!this._steps.length) {
|
2734
|
-
return this._executeNone();
|
2735
|
-
}
|
2736
2747
|
this.renderResult = new up.RenderResult({
|
2737
|
-
layer:
|
2748
|
+
layer: this._passRenderOptions.layer,
|
2738
2749
|
target: up.fragment.targetForSteps(this._steps),
|
2750
|
+
renderOptions: this._passRenderOptions,
|
2739
2751
|
});
|
2740
|
-
this._steps.
|
2741
|
-
|
2742
|
-
|
2752
|
+
if (!this._steps.length) {
|
2753
|
+
this._handleFocus(null, this._noneOptions);
|
2754
|
+
this._handleScroll(null, this._noneOptions);
|
2755
|
+
}
|
2756
|
+
else {
|
2757
|
+
this._steps.reverse();
|
2758
|
+
const motionEndPromises = this._steps.map((step) => this._executeStep(step));
|
2759
|
+
this.renderResult.finished = this._finish(motionEndPromises);
|
2760
|
+
}
|
2743
2761
|
return this.renderResult;
|
2744
2762
|
}
|
2745
|
-
_executeNone() {
|
2746
|
-
this._handleFocus(null, this._noneOptions);
|
2747
|
-
this._handleScroll(null, this._noneOptions);
|
2748
|
-
return up.RenderResult.buildNone();
|
2749
|
-
}
|
2750
2763
|
_finish(motionEndPromises) {
|
2751
2764
|
return __awaiter(this, void 0, void 0, function* () {
|
2752
2765
|
yield Promise.all(motionEndPromises);
|
@@ -2761,10 +2774,9 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2761
2774
|
this.renderResult.fragments.unshift(...newFragments);
|
2762
2775
|
}
|
2763
2776
|
_executeStep(step) {
|
2764
|
-
this.setReloadAttrs(step);
|
2765
2777
|
switch (step.placement) {
|
2766
2778
|
case 'swap': {
|
2767
|
-
let keepPlan =
|
2779
|
+
let keepPlan = up.fragment.keepPlan(step);
|
2768
2780
|
if (keepPlan) {
|
2769
2781
|
this._handleFocus(step.oldElement, step);
|
2770
2782
|
this._handleScroll(step.oldElement, step);
|
@@ -2777,10 +2789,8 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2777
2789
|
up.fragment.markAsDestroying(step.oldElement);
|
2778
2790
|
}, afterInsert: () => {
|
2779
2791
|
this._restoreDescendantKeepables(step);
|
2780
|
-
this.
|
2792
|
+
this._welcomeElement(step.newElement, step);
|
2781
2793
|
this._finalizeDescendantKeepables(step);
|
2782
|
-
up.hello(step.newElement, step);
|
2783
|
-
this._addToResult(step.newElement);
|
2784
2794
|
}, beforeDetach: () => {
|
2785
2795
|
up.script.clean(step.oldElement, { layer: step.layer });
|
2786
2796
|
}, afterDetach() {
|
@@ -2807,53 +2817,27 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2807
2817
|
let wrapper = e.wrapChildren(step.newElement);
|
2808
2818
|
let position = step.placement === 'before' ? 'afterbegin' : 'beforeend';
|
2809
2819
|
step.oldElement.insertAdjacentElement(position, wrapper);
|
2810
|
-
this.
|
2811
|
-
up.hello(wrapper, step);
|
2812
|
-
this._addToResult(wrapper);
|
2820
|
+
this._welcomeElement(wrapper, step);
|
2813
2821
|
this._handleFocus(wrapper, step);
|
2814
2822
|
this._handleScroll(wrapper, step);
|
2815
|
-
return up.animate(wrapper, step.
|
2823
|
+
return up.animate(wrapper, step.animation, step).then(() => e.unwrap(wrapper));
|
2816
2824
|
}
|
2817
2825
|
default: {
|
2818
2826
|
up.fail('Unknown placement: %o', step.placement);
|
2819
2827
|
}
|
2820
2828
|
}
|
2821
2829
|
}
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
let doKeep = e.booleanAttr(oldElement, 'up-keep');
|
2828
|
-
if (!doKeep) {
|
2829
|
-
return;
|
2830
|
-
}
|
2831
|
-
let partner;
|
2832
|
-
let partnerSelector = up.fragment.toTarget(oldElement);
|
2833
|
-
const lookupOpts = { layer: options.layer };
|
2834
|
-
if (options.descendantsOnly) {
|
2835
|
-
partner = up.fragment.get(newElement, partnerSelector, lookupOpts);
|
2836
|
-
}
|
2837
|
-
else {
|
2838
|
-
partner = e.subtreeFirst(newElement, partnerSelector, lookupOpts);
|
2839
|
-
}
|
2840
|
-
if (partner && e.booleanAttr(partner, 'up-keep') !== false) {
|
2841
|
-
const plan = {
|
2842
|
-
oldElement,
|
2843
|
-
newElement: partner,
|
2844
|
-
newData: up.script.data(partner),
|
2845
|
-
renderOptions: options,
|
2846
|
-
};
|
2847
|
-
if (!up.fragment.emitKeep(plan).defaultPrevented) {
|
2848
|
-
return plan;
|
2849
|
-
}
|
2850
|
-
}
|
2830
|
+
_welcomeElement(element, step) {
|
2831
|
+
this.responseDoc.finalizeElement(element);
|
2832
|
+
this.setReloadAttrs(step);
|
2833
|
+
up.hello(element, step);
|
2834
|
+
this._addToResult(element);
|
2851
2835
|
}
|
2852
2836
|
_preserveDescendantKeepables(step) {
|
2853
2837
|
const descendantKeepPlans = [];
|
2854
2838
|
if (step.keep) {
|
2855
2839
|
for (let keepable of step.oldElement.querySelectorAll('[up-keep]')) {
|
2856
|
-
let keepPlan =
|
2840
|
+
let keepPlan = up.fragment.keepPlan(Object.assign(Object.assign({}, step), { oldElement: keepable, descendantsOnly: true }));
|
2857
2841
|
if (keepPlan) {
|
2858
2842
|
const keepableClone = keepable.cloneNode(true);
|
2859
2843
|
keepable.insertAdjacentElement('beforebegin', keepableClone);
|
@@ -2868,7 +2852,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2868
2852
|
keepPlan.newElement.replaceWith(keepable);
|
2869
2853
|
}
|
2870
2854
|
else {
|
2871
|
-
|
2855
|
+
document.body.append(keepable);
|
2872
2856
|
}
|
2873
2857
|
descendantKeepPlans.push(keepPlan);
|
2874
2858
|
}
|
@@ -2878,12 +2862,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2878
2862
|
}
|
2879
2863
|
_restoreDescendantKeepables(step) {
|
2880
2864
|
for (let keepPlan of step.descendantKeepPlans) {
|
2881
|
-
|
2882
|
-
keepPlan.newElement.replaceWith(keepPlan.oldElement);
|
2883
|
-
}
|
2884
|
-
else {
|
2885
|
-
e.preservingReplace(keepPlan.newElement, keepPlan.oldElement);
|
2886
|
-
}
|
2865
|
+
keepPlan.newElement.replaceWith(keepPlan.oldElement);
|
2887
2866
|
for (let reviver of keepPlan.revivers) {
|
2888
2867
|
reviver();
|
2889
2868
|
}
|
@@ -3114,7 +3093,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
|
|
3114
3093
|
this.options.failTarget = ':none';
|
3115
3094
|
}
|
3116
3095
|
_updateContentFromResponse(finalRenderOptions) {
|
3117
|
-
if (finalRenderOptions.
|
3096
|
+
if (finalRenderOptions.didForceFailOptions) {
|
3118
3097
|
up.puts('up.render()', 'Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)');
|
3119
3098
|
}
|
3120
3099
|
this._augmentOptionsFromResponse(finalRenderOptions);
|
@@ -3268,9 +3247,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3268
3247
|
return this._seekPlan(this._executePlan.bind(this)) || this._cannotMatchPostflightTarget();
|
3269
3248
|
}
|
3270
3249
|
_executePlan(matchedPlan) {
|
3271
|
-
|
3272
|
-
result.options = this.options;
|
3273
|
-
return result;
|
3250
|
+
return matchedPlan.execute(this._getResponseDoc(), this._onPlanApplicable.bind(this, matchedPlan));
|
3274
3251
|
}
|
3275
3252
|
_isApplicablePlanError(error) {
|
3276
3253
|
return !(error instanceof up.CannotMatch);
|
@@ -3347,7 +3324,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3347
3324
|
else if (this._layers.length === 0) {
|
3348
3325
|
this._cannotMatchLayer();
|
3349
3326
|
}
|
3350
|
-
else if (this.options.
|
3327
|
+
else if (this.options.didForceFailOptions) {
|
3351
3328
|
throw new up.CannotMatch('No target selector given for failed responses (https://unpoly.com/failed-responses)');
|
3352
3329
|
}
|
3353
3330
|
else {
|
@@ -3976,6 +3953,9 @@ up.FieldWatcher = class FieldWatcher {
|
|
3976
3953
|
if (this._root.matches('input[type=radio]')) {
|
3977
3954
|
fail('Use %s with the container of a radio group, not with an individual radio button (%o)');
|
3978
3955
|
}
|
3956
|
+
if (up.form.isField(this._root) && !this._root.name) {
|
3957
|
+
fail('%s can only watch fields with a name (%o)');
|
3958
|
+
}
|
3979
3959
|
}
|
3980
3960
|
_trackAbort() {
|
3981
3961
|
let guard = ({ target }) => target.contains(this._region);
|
@@ -4068,9 +4048,9 @@ up.FieldWatcher = class FieldWatcher {
|
|
4068
4048
|
return up.Params.fromContainer(this._root).toObject();
|
4069
4049
|
}
|
4070
4050
|
_check(event, fieldOptions = {}) {
|
4071
|
-
up.log.putsEvent(event);
|
4072
4051
|
const values = this._readFieldValues();
|
4073
4052
|
if (this._isNewValues(values)) {
|
4053
|
+
up.log.putsEvent(event);
|
4074
4054
|
this._scheduleValues(values, fieldOptions);
|
4075
4055
|
}
|
4076
4056
|
}
|
@@ -4111,7 +4091,7 @@ up.Switcher = class Switcher {
|
|
4111
4091
|
_trackNewSwitchees() {
|
4112
4092
|
let filter = (matches) => {
|
4113
4093
|
let scope = this._scope;
|
4114
|
-
return u.filter(matches, (match) => scope.contains(match));
|
4094
|
+
return u.filter(matches, (match) => scope === null || scope === void 0 ? void 0 : scope.contains(match));
|
4115
4095
|
};
|
4116
4096
|
let onSwitcheeAdded = (switchee) => this._switchSwitchee(switchee);
|
4117
4097
|
return up.fragment.trackSelector(this._switcheeSelector, { filter }, onSwitcheeAdded);
|
@@ -4142,10 +4122,11 @@ up.Switcher = class Switcher {
|
|
4142
4122
|
}
|
4143
4123
|
}
|
4144
4124
|
let log = ['Switching %o', switchee];
|
4145
|
-
up.emit(switchee, 'up:form:switch', { field: this._root,
|
4125
|
+
up.emit(switchee, 'up:form:switch', { field: this._root, fieldTokens, log });
|
4146
4126
|
}
|
4147
4127
|
_findSwitchees() {
|
4148
|
-
|
4128
|
+
let scope = this._scope;
|
4129
|
+
return scope ? up.fragment.subtree(scope, this._switcheeSelector) : [];
|
4149
4130
|
}
|
4150
4131
|
get _scope() {
|
4151
4132
|
if (this._regionSelector) {
|
@@ -4159,45 +4140,17 @@ up.Switcher = class Switcher {
|
|
4159
4140
|
return u.getSimpleTokens(str, { json: true });
|
4160
4141
|
}
|
4161
4142
|
_buildFieldTokens() {
|
4162
|
-
var _a
|
4143
|
+
var _a;
|
4144
|
+
let values = up.Params.fromContainer(this._root).values();
|
4145
|
+
let tokens = [...values];
|
4146
|
+
let anyPresent = u.some(values, u.isPresent);
|
4147
|
+
tokens.push(anyPresent ? ':present' : ':blank');
|
4163
4148
|
let fields = up.form.fields(this._root);
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
if (field.matches('input[type=checkbox]')) {
|
4168
|
-
if (field.checked) {
|
4169
|
-
value = field.value;
|
4170
|
-
meta = ':checked';
|
4171
|
-
}
|
4172
|
-
else {
|
4173
|
-
meta = ':unchecked';
|
4174
|
-
}
|
4175
|
-
}
|
4176
|
-
else if (field.matches('input[type=radio]')) {
|
4177
|
-
let checkedButton = ((_b = (_a = up.migrate).checkedRadioButtonForSwitch) === null || _b === void 0 ? void 0 : _b.call(_a, field)) || u.find(fields, 'checked');
|
4178
|
-
if (checkedButton) {
|
4179
|
-
meta = ':checked';
|
4180
|
-
value = checkedButton.value;
|
4181
|
-
}
|
4182
|
-
else {
|
4183
|
-
meta = ':unchecked';
|
4184
|
-
}
|
4185
|
-
}
|
4186
|
-
else {
|
4187
|
-
value = field.value;
|
4188
|
-
}
|
4189
|
-
const values = [];
|
4190
|
-
if (u.isPresent(value)) {
|
4191
|
-
values.push(value);
|
4192
|
-
values.push(':present');
|
4193
|
-
}
|
4194
|
-
else {
|
4195
|
-
values.push(':blank');
|
4149
|
+
if ((_a = fields[0]) === null || _a === void 0 ? void 0 : _a.matches('[type=radio], [type=checkbox]')) {
|
4150
|
+
let anyChecked = u.some(fields, 'checked');
|
4151
|
+
tokens.push(anyChecked ? ':checked' : ':unchecked');
|
4196
4152
|
}
|
4197
|
-
|
4198
|
-
values.push(meta);
|
4199
|
-
}
|
4200
|
-
return values;
|
4153
|
+
return tokens;
|
4201
4154
|
}
|
4202
4155
|
};
|
4203
4156
|
|
@@ -4714,7 +4667,7 @@ up.FragmentPolling = class FragmentPolling {
|
|
4714
4667
|
if (this._state === 'started') {
|
4715
4668
|
this._clearReloadTimer();
|
4716
4669
|
this._state = 'stopped';
|
4717
|
-
(_a = this.
|
4670
|
+
(_a = this._unbindEvents) === null || _a === void 0 ? void 0 : _a.call(this);
|
4718
4671
|
}
|
4719
4672
|
}
|
4720
4673
|
forceStart(options) {
|
@@ -4727,8 +4680,8 @@ up.FragmentPolling = class FragmentPolling {
|
|
4727
4680
|
this.forceStarted = false;
|
4728
4681
|
}
|
4729
4682
|
_ensureEventsBound() {
|
4730
|
-
if (!this.
|
4731
|
-
this.
|
4683
|
+
if (!this._unbindEvents) {
|
4684
|
+
this._unbindEvents = up.on('visibilitychange up:layer:opened up:layer:dismissed up:layer:accepted', this._onVisibilityChange.bind(this));
|
4732
4685
|
}
|
4733
4686
|
}
|
4734
4687
|
_onVisibilityChange() {
|
@@ -4927,14 +4880,16 @@ up.Layer = class Layer extends up.Record {
|
|
4927
4880
|
}
|
4928
4881
|
constructor(options = {}) {
|
4929
4882
|
super(options);
|
4930
|
-
|
4931
|
-
throw "missing { mode } option";
|
4932
|
-
}
|
4883
|
+
u.assert(this.mode);
|
4933
4884
|
}
|
4934
4885
|
setupHandlers() {
|
4935
4886
|
up.link.convertClicks(this);
|
4887
|
+
this._unbindLocationChanged = up.on('up:location:changed', (event) => this._onBrowserLocationChanged(event));
|
4888
|
+
}
|
4889
|
+
teardownHandlers() {
|
4890
|
+
var _a;
|
4891
|
+
(_a = this._unbindLocationChanged) === null || _a === void 0 ? void 0 : _a.call(this);
|
4936
4892
|
}
|
4937
|
-
teardownHandlers() { }
|
4938
4893
|
mainTargets() {
|
4939
4894
|
return up.layer.mainTargets(this.mode);
|
4940
4895
|
}
|
@@ -5034,28 +4989,28 @@ up.Layer = class Layer extends up.Record {
|
|
5034
4989
|
return !this.element.isConnected;
|
5035
4990
|
}
|
5036
4991
|
saveHistory() {
|
5037
|
-
|
5038
|
-
|
5039
|
-
|
5040
|
-
|
5041
|
-
|
5042
|
-
|
4992
|
+
u.assert(this.isFront());
|
4993
|
+
if (!this.showsLiveHistory())
|
4994
|
+
return;
|
4995
|
+
this._savedTitle = this.title;
|
4996
|
+
this._savedMetaTags = this.metaTags;
|
4997
|
+
this._savedLocation = this.location;
|
4998
|
+
this._savedLang = this.lang;
|
5043
4999
|
}
|
5044
5000
|
restoreHistory() {
|
5045
|
-
if (!this.showsLiveHistory())
|
5001
|
+
if (!this.showsLiveHistory())
|
5046
5002
|
return;
|
5003
|
+
if (this._savedLocation) {
|
5004
|
+
up.history.push(this._savedLocation);
|
5047
5005
|
}
|
5048
|
-
if (this.
|
5049
|
-
|
5006
|
+
if (this._savedTitle) {
|
5007
|
+
document.title = this._savedTitle;
|
5050
5008
|
}
|
5051
|
-
if (this.
|
5052
|
-
|
5009
|
+
if (this._savedMetaTags) {
|
5010
|
+
up.history.updateMetaTags(this._savedMetaTags);
|
5053
5011
|
}
|
5054
|
-
if (this.
|
5055
|
-
up.history.
|
5056
|
-
}
|
5057
|
-
if (u.isString(this.savedLang)) {
|
5058
|
-
up.history.updateLang(this.savedLang);
|
5012
|
+
if (u.isString(this._savedLang)) {
|
5013
|
+
up.history.updateLang(this._savedLang);
|
5059
5014
|
}
|
5060
5015
|
}
|
5061
5016
|
asCurrent(fn) {
|
@@ -5064,32 +5019,37 @@ up.Layer = class Layer extends up.Record {
|
|
5064
5019
|
updateHistory(options) {
|
5065
5020
|
var _a, _b;
|
5066
5021
|
if (u.isString(options.location)) {
|
5067
|
-
this.location
|
5022
|
+
this._updateLocation(options.location, { push: true });
|
5068
5023
|
}
|
5069
5024
|
if (up.history.config.updateMetaTags && u.isList(options.metaTags)) {
|
5070
5025
|
(_b = (_a = up.migrate) === null || _a === void 0 ? void 0 : _a.warnOfHungryMetaTags) === null || _b === void 0 ? void 0 : _b.call(_a, options.metaTags);
|
5071
|
-
this.
|
5026
|
+
this._updateMetaTags(options.metaTags);
|
5072
5027
|
}
|
5073
5028
|
if (u.isString(options.title)) {
|
5074
|
-
this.
|
5029
|
+
this._updateTitle(options.title);
|
5075
5030
|
}
|
5076
5031
|
if (u.isString(options.lang)) {
|
5077
|
-
this.
|
5032
|
+
this._updateLang(options.lang);
|
5078
5033
|
}
|
5079
5034
|
}
|
5080
5035
|
showsLiveHistory() {
|
5081
5036
|
return this.history && this.isFront();
|
5082
5037
|
}
|
5038
|
+
_onBrowserLocationChanged({ location }) {
|
5039
|
+
if (this.showsLiveHistory()) {
|
5040
|
+
this._updateLocation(location, { push: false });
|
5041
|
+
}
|
5042
|
+
}
|
5083
5043
|
get title() {
|
5084
5044
|
if (this.showsLiveHistory()) {
|
5085
5045
|
return document.title;
|
5086
5046
|
}
|
5087
5047
|
else {
|
5088
|
-
return this.
|
5048
|
+
return this._savedTitle;
|
5089
5049
|
}
|
5090
5050
|
}
|
5091
|
-
|
5092
|
-
this.
|
5051
|
+
_updateTitle(title) {
|
5052
|
+
this._savedTitle = title;
|
5093
5053
|
if (this.showsLiveHistory()) {
|
5094
5054
|
document.title = title;
|
5095
5055
|
}
|
@@ -5099,11 +5059,11 @@ up.Layer = class Layer extends up.Record {
|
|
5099
5059
|
return up.history.findMetaTags();
|
5100
5060
|
}
|
5101
5061
|
else {
|
5102
|
-
return this.
|
5062
|
+
return this._savedMetaTags;
|
5103
5063
|
}
|
5104
5064
|
}
|
5105
|
-
|
5106
|
-
this.
|
5065
|
+
_updateMetaTags(metaTags) {
|
5066
|
+
this._savedMetaTags = metaTags;
|
5107
5067
|
if (this.showsLiveHistory()) {
|
5108
5068
|
up.history.updateMetaTags(metaTags);
|
5109
5069
|
}
|
@@ -5113,11 +5073,11 @@ up.Layer = class Layer extends up.Record {
|
|
5113
5073
|
return up.history.getLang();
|
5114
5074
|
}
|
5115
5075
|
else {
|
5116
|
-
return this.
|
5076
|
+
return this._savedLang;
|
5117
5077
|
}
|
5118
5078
|
}
|
5119
|
-
|
5120
|
-
this.
|
5079
|
+
_updateLang(lang) {
|
5080
|
+
this._savedLang = lang;
|
5121
5081
|
if (this.showsLiveHistory()) {
|
5122
5082
|
up.history.updateLang(lang);
|
5123
5083
|
}
|
@@ -5127,20 +5087,18 @@ up.Layer = class Layer extends up.Record {
|
|
5127
5087
|
return up.history.location;
|
5128
5088
|
}
|
5129
5089
|
else {
|
5130
|
-
return this.
|
5090
|
+
return this._savedLocation;
|
5131
5091
|
}
|
5132
5092
|
}
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5141
|
-
|
5142
|
-
this.emit('up:layer:location:changed', { location, log: false });
|
5143
|
-
}
|
5093
|
+
_updateLocation(newLocation, { push }) {
|
5094
|
+
let prevSavedLocation = this._savedLocation;
|
5095
|
+
let liveLocation = up.history.location;
|
5096
|
+
this._savedLocation = newLocation;
|
5097
|
+
if (newLocation !== liveLocation && this.showsLiveHistory() && push) {
|
5098
|
+
up.history.push(newLocation);
|
5099
|
+
}
|
5100
|
+
if (newLocation !== prevSavedLocation && !this.opening) {
|
5101
|
+
this.emit('up:layer:location:changed', { location: newLocation, previousLocation: prevSavedLocation, log: false });
|
5144
5102
|
}
|
5145
5103
|
}
|
5146
5104
|
selector(part) {
|
@@ -5286,7 +5244,7 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
|
5286
5244
|
});
|
5287
5245
|
}
|
5288
5246
|
else {
|
5289
|
-
this.
|
5247
|
+
this._unbindParentClicked = this.parent.on('up:click', (event, element) => {
|
5290
5248
|
if (!up.layer.isWithinForeignOverlay(element)) {
|
5291
5249
|
const originClicked = this.origin && this.origin.contains(element);
|
5292
5250
|
this._onOutsideClicked(event, originClicked);
|
@@ -5295,7 +5253,7 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
|
5295
5253
|
}
|
5296
5254
|
}
|
5297
5255
|
if (this._supportsDismissMethod('key')) {
|
5298
|
-
this.
|
5256
|
+
this._unbindEscapePressed = up.event.onEscape((event) => this.onEscapePressed(event));
|
5299
5257
|
}
|
5300
5258
|
this.registerAttrCloser('up-accept', (value, closeOptions) => {
|
5301
5259
|
this.accept(value, closeOptions);
|
@@ -5392,8 +5350,8 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
|
5392
5350
|
teardownHandlers() {
|
5393
5351
|
var _b, _c;
|
5394
5352
|
super.teardownHandlers();
|
5395
|
-
(_b = this.
|
5396
|
-
(_c = this.
|
5353
|
+
(_b = this._unbindParentClicked) === null || _b === void 0 ? void 0 : _b.call(this);
|
5354
|
+
(_c = this._unbindEscapePressed) === null || _c === void 0 ? void 0 : _c.call(this);
|
5397
5355
|
this.overlayFocus.teardown();
|
5398
5356
|
}
|
5399
5357
|
destroyElements(options) {
|
@@ -5901,6 +5859,14 @@ up.LinkCurrentURLs = class LinkCurrentURLs {
|
|
5901
5859
|
this._upHREF === normalizedLocation ||
|
5902
5860
|
((_b = (_a = this._aliasPattern) === null || _a === void 0 ? void 0 : _a.test) === null || _b === void 0 ? void 0 : _b.call(_a, normalizedLocation, false)));
|
5903
5861
|
}
|
5862
|
+
isAnyCurrent(normalizedLocations) {
|
5863
|
+
return normalizedLocations.some((normalizedLocation) => {
|
5864
|
+
var _a, _b;
|
5865
|
+
return (this._href === normalizedLocation ||
|
5866
|
+
this._upHREF === normalizedLocation ||
|
5867
|
+
((_b = (_a = this._aliasPattern) === null || _a === void 0 ? void 0 : _a.test) === null || _b === void 0 ? void 0 : _b.call(_a, normalizedLocation, false)));
|
5868
|
+
});
|
5869
|
+
}
|
5904
5870
|
};
|
5905
5871
|
|
5906
5872
|
|
@@ -6244,15 +6210,12 @@ up.Params = class Params {
|
|
6244
6210
|
return formData;
|
6245
6211
|
}
|
6246
6212
|
toQuery() {
|
6247
|
-
let
|
6248
|
-
parts =
|
6213
|
+
let simpleEntries = this.withoutBinaryEntries().entries;
|
6214
|
+
let parts = simpleEntries.map(this._arrayEntryToQuery);
|
6249
6215
|
return parts.join('&');
|
6250
6216
|
}
|
6251
6217
|
_arrayEntryToQuery(entry) {
|
6252
6218
|
const { value } = entry;
|
6253
|
-
if (this._isBinaryValue(value)) {
|
6254
|
-
return;
|
6255
|
-
}
|
6256
6219
|
let query = encodeURIComponent(entry.name);
|
6257
6220
|
if (u.isGiven(value)) {
|
6258
6221
|
query += "=";
|
@@ -6260,12 +6223,15 @@ up.Params = class Params {
|
|
6260
6223
|
}
|
6261
6224
|
return query;
|
6262
6225
|
}
|
6263
|
-
|
6226
|
+
_isBinaryEntry({ value }) {
|
6264
6227
|
return value instanceof Blob;
|
6265
6228
|
}
|
6266
|
-
|
6267
|
-
|
6268
|
-
|
6229
|
+
hasBinaryEntries() {
|
6230
|
+
return u.some(this.entries, this._isBinaryEntry);
|
6231
|
+
}
|
6232
|
+
withoutBinaryEntries() {
|
6233
|
+
let simpleEntries = u.reject(this.entries, this._isBinaryEntry);
|
6234
|
+
return new this.constructor(simpleEntries);
|
6269
6235
|
}
|
6270
6236
|
toURL(base) {
|
6271
6237
|
let parts = [base, this.toQuery()];
|
@@ -6295,9 +6261,15 @@ up.Params = class Params {
|
|
6295
6261
|
this._addAllFromObject(raw);
|
6296
6262
|
}
|
6297
6263
|
else {
|
6298
|
-
up.fail("
|
6264
|
+
up.fail("Unsupported params type: %o", raw);
|
6299
6265
|
}
|
6300
6266
|
}
|
6267
|
+
keys() {
|
6268
|
+
return u.map(this.entries, 'name');
|
6269
|
+
}
|
6270
|
+
values() {
|
6271
|
+
return u.map(this.entries, 'value');
|
6272
|
+
}
|
6301
6273
|
_addAllFromObject(object) {
|
6302
6274
|
for (let key in object) {
|
6303
6275
|
const value = object[key];
|
@@ -6350,16 +6322,11 @@ up.Params = class Params {
|
|
6350
6322
|
return entry === null || entry === void 0 ? void 0 : entry.value;
|
6351
6323
|
}
|
6352
6324
|
getAll(name) {
|
6353
|
-
|
6354
|
-
|
6355
|
-
}
|
6356
|
-
else {
|
6357
|
-
const entries = u.map(this.entries, this._matchEntryFn(name));
|
6358
|
-
return u.map(entries, 'value');
|
6359
|
-
}
|
6325
|
+
const entries = u.filter(this.entries, this._matchEntryFn(name));
|
6326
|
+
return u.map(entries, 'value');
|
6360
6327
|
}
|
6361
6328
|
_isArrayKey(key) {
|
6362
|
-
return
|
6329
|
+
return u.evalOption(up.form.config.arrayParam, key);
|
6363
6330
|
}
|
6364
6331
|
[u.isBlank.key]() {
|
6365
6332
|
return this.entries.length === 0;
|
@@ -6422,11 +6389,15 @@ up.Params = class Params {
|
|
6422
6389
|
static stripURL(url) {
|
6423
6390
|
return u.normalizeURL(url, { search: false });
|
6424
6391
|
}
|
6425
|
-
static merge(...objects) {
|
6426
|
-
|
6427
|
-
|
6428
|
-
|
6429
|
-
|
6392
|
+
static merge(start, ...objects) {
|
6393
|
+
let merged = u.copy(start);
|
6394
|
+
for (let object of objects) {
|
6395
|
+
let other = u.wrapValue(this, object);
|
6396
|
+
for (let key of other.keys())
|
6397
|
+
merged.delete(key);
|
6398
|
+
merged.addAll(other);
|
6399
|
+
}
|
6400
|
+
return merged;
|
6430
6401
|
}
|
6431
6402
|
};
|
6432
6403
|
|
@@ -6728,12 +6699,13 @@ up.RenderOptions = (function () {
|
|
6728
6699
|
return overrides;
|
6729
6700
|
}
|
6730
6701
|
function deriveFailOptions(preprocessedOptions) {
|
6702
|
+
let markFailure = { didFail: true };
|
6731
6703
|
let overrides = failOverrides(preprocessedOptions);
|
6732
6704
|
if (preprocessedOptions.failOptions) {
|
6733
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, preprocessedOptions.defaults), u.pick(preprocessedOptions, SHARED_KEYS)), overrides), {
|
6705
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, preprocessedOptions.defaults), u.pick(preprocessedOptions, SHARED_KEYS)), overrides), { didForceFailOptions: true }), markFailure);
|
6734
6706
|
}
|
6735
6707
|
else {
|
6736
|
-
return Object.assign(Object.assign({}, preprocessedOptions), overrides);
|
6708
|
+
return Object.assign(Object.assign(Object.assign({}, preprocessedOptions), overrides), markFailure);
|
6737
6709
|
}
|
6738
6710
|
}
|
6739
6711
|
return {
|
@@ -6767,13 +6739,14 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
6767
6739
|
'fragments',
|
6768
6740
|
'layer',
|
6769
6741
|
'target',
|
6770
|
-
'
|
6742
|
+
'renderOptions',
|
6771
6743
|
'finished',
|
6772
6744
|
];
|
6773
6745
|
}
|
6774
6746
|
defaults() {
|
6775
6747
|
return {
|
6776
6748
|
fragments: [],
|
6749
|
+
finished: Promise.resolve(),
|
6777
6750
|
};
|
6778
6751
|
}
|
6779
6752
|
get none() {
|
@@ -6782,28 +6755,20 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
6782
6755
|
get fragment() {
|
6783
6756
|
return this.fragments[0];
|
6784
6757
|
}
|
6758
|
+
get ok() {
|
6759
|
+
return !this.renderOptions.didFail;
|
6760
|
+
}
|
6785
6761
|
static both(main, extension, mergeFinished = true) {
|
6786
|
-
if (!extension)
|
6762
|
+
if (!extension) {
|
6787
6763
|
return main;
|
6788
|
-
|
6789
|
-
|
6790
|
-
layer: main.layer,
|
6791
|
-
options: main.options,
|
6792
|
-
fragments: main.fragments.concat(extension.fragments),
|
6793
|
-
finished: (mergeFinished && this.mergeFinished(main, extension))
|
6794
|
-
});
|
6764
|
+
}
|
6765
|
+
return new this(Object.assign(Object.assign({}, main), { fragments: main.fragments.concat(extension.fragments), finished: (mergeFinished && this.mergeFinished(main, extension)) }));
|
6795
6766
|
}
|
6796
6767
|
static mergeFinished(main, extension) {
|
6797
6768
|
return __awaiter(this, void 0, void 0, function* () {
|
6798
6769
|
return this.both(yield main.finished, yield extension.finished, false);
|
6799
6770
|
});
|
6800
6771
|
}
|
6801
|
-
static buildNone() {
|
6802
|
-
return new this({
|
6803
|
-
target: ':none',
|
6804
|
-
finished: Promise.resolve(),
|
6805
|
-
});
|
6806
|
-
}
|
6807
6772
|
};
|
6808
6773
|
|
6809
6774
|
|
@@ -7290,15 +7255,6 @@ up.Request.Cache = class Cache {
|
|
7290
7255
|
this._limitSize();
|
7291
7256
|
});
|
7292
7257
|
}
|
7293
|
-
alias(existingCachedRequest, newRequest) {
|
7294
|
-
existingCachedRequest = this.get(existingCachedRequest);
|
7295
|
-
if (!existingCachedRequest)
|
7296
|
-
return;
|
7297
|
-
newRequest = this._wrap(newRequest);
|
7298
|
-
this.track(existingCachedRequest, newRequest, { force: true });
|
7299
|
-
this.put(newRequest);
|
7300
|
-
return newRequest;
|
7301
|
-
}
|
7302
7258
|
track(existingRequest, newRequest, options = {}) {
|
7303
7259
|
var _a;
|
7304
7260
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -7397,7 +7353,7 @@ up.Request.Queue = class Queue {
|
|
7397
7353
|
}
|
7398
7354
|
asap(request) {
|
7399
7355
|
request.runQueuedCallbacks();
|
7400
|
-
u.always(request, (
|
7356
|
+
u.always(request, () => this._onRequestSettled(request));
|
7401
7357
|
this._scheduleSlowTimer(request);
|
7402
7358
|
this._queueRequest(request);
|
7403
7359
|
queueMicrotask(() => this._poke());
|
@@ -7437,11 +7393,8 @@ up.Request.Queue = class Queue {
|
|
7437
7393
|
this._currentRequests.push(request);
|
7438
7394
|
}
|
7439
7395
|
}
|
7440
|
-
_onRequestSettled(request
|
7396
|
+
_onRequestSettled(request) {
|
7441
7397
|
u.remove(this._currentRequests, request) || u.remove(this._queuedRequests, request);
|
7442
|
-
if ((responseOrError instanceof up.Response) && responseOrError.ok) {
|
7443
|
-
up.network.registerAliasForRedirect(request, responseOrError);
|
7444
|
-
}
|
7445
7398
|
queueMicrotask(() => this._poke());
|
7446
7399
|
u.task(() => this._checkForRecover());
|
7447
7400
|
}
|
@@ -7501,7 +7454,7 @@ up.Request.FormRenderer = class FormRenderer {
|
|
7501
7454
|
this._request = request;
|
7502
7455
|
}
|
7503
7456
|
buildAndSubmit() {
|
7504
|
-
this.params =
|
7457
|
+
this.params = this._request.params.withoutBinaryEntries();
|
7505
7458
|
let action = this._request.url;
|
7506
7459
|
let { method } = this._request;
|
7507
7460
|
const paramsFromQuery = up.Params.fromURL(action);
|
@@ -7578,7 +7531,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
7578
7531
|
this._contentType = this._request.contentType;
|
7579
7532
|
if (!this._payload && this._request.allowsPayload()) {
|
7580
7533
|
if (!this._contentType) {
|
7581
|
-
this._contentType = this._params.
|
7534
|
+
this._contentType = this._params.hasBinaryEntries() ? CONTENT_TYPE_FORM_DATA : CONTENT_TYPE_URL_ENCODED;
|
7582
7535
|
}
|
7583
7536
|
if (this._contentType === CONTENT_TYPE_FORM_DATA) {
|
7584
7537
|
this._contentType = null;
|
@@ -7678,6 +7631,20 @@ up.Response = class Response extends up.Record {
|
|
7678
7631
|
get description() {
|
7679
7632
|
return `HTTP ${this.status} response to ${this.request.description}`;
|
7680
7633
|
}
|
7634
|
+
get redirect() {
|
7635
|
+
return (this.url !== this.request.url) || (this.method !== this.request.method);
|
7636
|
+
}
|
7637
|
+
get redirectRequest() {
|
7638
|
+
if (!this.redirect)
|
7639
|
+
return;
|
7640
|
+
let finalRequest = u.variant(this.request, {
|
7641
|
+
method: this.method,
|
7642
|
+
url: this.url,
|
7643
|
+
cacheRoute: null,
|
7644
|
+
});
|
7645
|
+
up.cache.track(this.request, finalRequest, { force: true });
|
7646
|
+
return finalRequest;
|
7647
|
+
}
|
7681
7648
|
};
|
7682
7649
|
|
7683
7650
|
|
@@ -8239,7 +8206,7 @@ up.framework = (function () {
|
|
8239
8206
|
function emitReset() {
|
8240
8207
|
up.emit('up:framework:reset', { log: false });
|
8241
8208
|
}
|
8242
|
-
function boot() {
|
8209
|
+
function boot({ mode = 'manual' } = {}) {
|
8243
8210
|
if (readyState !== 'configuring') {
|
8244
8211
|
console.error('Unpoly has already booted');
|
8245
8212
|
return;
|
@@ -8247,9 +8214,9 @@ up.framework = (function () {
|
|
8247
8214
|
let issue = supportIssue();
|
8248
8215
|
if (!issue) {
|
8249
8216
|
readyState = 'booting';
|
8250
|
-
up.emit('up:framework:boot', { log: false });
|
8217
|
+
up.emit('up:framework:boot', { mode, log: false });
|
8251
8218
|
readyState = 'booted';
|
8252
|
-
up.emit('up:framework:booted', { log: false });
|
8219
|
+
up.emit('up:framework:booted', { mode, log: false });
|
8253
8220
|
}
|
8254
8221
|
else {
|
8255
8222
|
console.error("Unpoly cannot boot: %s", issue);
|
@@ -8273,7 +8240,7 @@ up.framework = (function () {
|
|
8273
8240
|
console.debug('Call up.boot() after you have configured Unpoly');
|
8274
8241
|
}
|
8275
8242
|
else {
|
8276
|
-
document.addEventListener('DOMContentLoaded', boot);
|
8243
|
+
document.addEventListener('DOMContentLoaded', () => boot({ mode: 'auto' }));
|
8277
8244
|
}
|
8278
8245
|
readyState = 'configuring';
|
8279
8246
|
}
|
@@ -8707,6 +8674,7 @@ up.script = (function () {
|
|
8707
8674
|
'[up-expand]': -300,
|
8708
8675
|
'[data-method]': -400,
|
8709
8676
|
'[data-confirm]': -400,
|
8677
|
+
'[up-keep]': 9999999999,
|
8710
8678
|
};
|
8711
8679
|
let registeredCompilers = [];
|
8712
8680
|
let registeredMacros = [];
|
@@ -8980,6 +8948,8 @@ up.history = (function () {
|
|
8980
8948
|
placeAdoptedHistoryEntry('replaceState', location, trackOptions);
|
8981
8949
|
}
|
8982
8950
|
function push(location, trackOptions) {
|
8951
|
+
if (isLocation(location))
|
8952
|
+
return;
|
8983
8953
|
placeAdoptedHistoryEntry('pushState', location, trackOptions);
|
8984
8954
|
}
|
8985
8955
|
function placeAdoptedHistoryEntry(method, location, trackOptions) {
|
@@ -9026,7 +8996,7 @@ up.history = (function () {
|
|
9026
8996
|
restoreLocation(event.location);
|
9027
8997
|
}
|
9028
8998
|
else if (event.reason === 'hash') {
|
9029
|
-
up.viewport.revealHash(
|
8999
|
+
up.viewport.revealHash(location.hash, { strong: true });
|
9030
9000
|
}
|
9031
9001
|
}
|
9032
9002
|
function findMetaTags(head = document.head) {
|
@@ -9067,14 +9037,13 @@ up.history = (function () {
|
|
9067
9037
|
adopt();
|
9068
9038
|
}
|
9069
9039
|
}
|
9070
|
-
up.on('up:framework:boot', function () {
|
9040
|
+
up.on('up:framework:boot', function ({ mode }) {
|
9071
9041
|
trackCurrentLocation({ reason: null, alreadyHandled: true });
|
9072
9042
|
patchHistoryAPI();
|
9073
9043
|
adoptInitialHistoryEntry();
|
9074
|
-
|
9075
|
-
|
9076
|
-
|
9077
|
-
u.task(up.viewport.revealHash);
|
9044
|
+
if (mode === 'auto') {
|
9045
|
+
up.viewport.revealHash(location.hash, { strong: true });
|
9046
|
+
}
|
9078
9047
|
});
|
9079
9048
|
up.on(window, 'hashchange, popstate', () => {
|
9080
9049
|
trackCurrentLocation({ reason: 'detect', alreadyHandled: false });
|
@@ -9203,6 +9172,7 @@ up.fragment = (function () {
|
|
9203
9172
|
autoScroll: ['hash', 'layer-if-main'],
|
9204
9173
|
autoRevalidate: (response) => response.expired,
|
9205
9174
|
skipResponse: defaultSkipResponse,
|
9175
|
+
normalizeKeepHTML: defaultNormalizeKeepHTML
|
9206
9176
|
}));
|
9207
9177
|
u.delegate(config, ['mainTargets'], () => up.layer.config.any);
|
9208
9178
|
function defaultSkipResponse({ response, expiredResponse }) {
|
@@ -9238,6 +9208,77 @@ up.fragment = (function () {
|
|
9238
9208
|
const options = parseTargetAndOptions(args);
|
9239
9209
|
return render(Object.assign(Object.assign({}, options), { navigate: true }));
|
9240
9210
|
});
|
9211
|
+
function emitFragmentKeep(keepPlan) {
|
9212
|
+
let { oldElement, newElement: newFragment, newData, renderOptions } = keepPlan;
|
9213
|
+
const log = ['Keeping fragment %o', oldElement];
|
9214
|
+
const callback = e.callbackAttr(keepPlan.oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });
|
9215
|
+
const event = up.event.build('up:fragment:keep', { newFragment, newData, renderOptions });
|
9216
|
+
return up.emit(oldElement, event, { log, callback });
|
9217
|
+
}
|
9218
|
+
function findKeepPlan(options) {
|
9219
|
+
if (options.keep === false)
|
9220
|
+
return;
|
9221
|
+
const { oldElement, newElement } = options;
|
9222
|
+
let oldElementMode = keepMode(oldElement);
|
9223
|
+
if (!oldElementMode) {
|
9224
|
+
return;
|
9225
|
+
}
|
9226
|
+
let partner;
|
9227
|
+
let partnerSelector = up.fragment.toTarget(oldElement);
|
9228
|
+
const lookupOpts = { layer: options.layer };
|
9229
|
+
if (options.descendantsOnly) {
|
9230
|
+
partner = up.fragment.get(newElement, partnerSelector, lookupOpts);
|
9231
|
+
}
|
9232
|
+
else {
|
9233
|
+
partner = e.subtreeFirst(newElement, partnerSelector, lookupOpts);
|
9234
|
+
}
|
9235
|
+
if (!partner)
|
9236
|
+
return;
|
9237
|
+
let partnerMode = keepMode(partner);
|
9238
|
+
if (partnerMode === false)
|
9239
|
+
return;
|
9240
|
+
let oldIdentity = keepIdentity(oldElement, oldElementMode);
|
9241
|
+
let partnerIdentity = keepIdentity(partner, oldElementMode);
|
9242
|
+
if (!u.isEqual(oldIdentity, partnerIdentity))
|
9243
|
+
return;
|
9244
|
+
const plan = {
|
9245
|
+
oldElement,
|
9246
|
+
newElement: partner,
|
9247
|
+
newData: up.script.data(partner),
|
9248
|
+
renderOptions: options,
|
9249
|
+
};
|
9250
|
+
if (emitFragmentKeep(plan).defaultPrevented)
|
9251
|
+
return;
|
9252
|
+
return plan;
|
9253
|
+
}
|
9254
|
+
function keepIdentity(element, mode = keepMode(element)) {
|
9255
|
+
var _a;
|
9256
|
+
return (_a = element.upKeepIdentity) !== null && _a !== void 0 ? _a : (element.upKeepIdentity = u.copy(buildKeepIdentity(element, mode)));
|
9257
|
+
}
|
9258
|
+
function defaultNormalizeKeepHTML(html) {
|
9259
|
+
let tagPattern = /<[^<]+>/g;
|
9260
|
+
let attrs = ['up-etag', 'up-source', 'up-time', 'nonce', ...up.script.config.nonceableAttributes];
|
9261
|
+
let attrPattern = new RegExp(`\\s+(${attrs.join('|')})="[^"]*"`, 'g');
|
9262
|
+
let cleanTag = (match) => match.replace(attrPattern, '');
|
9263
|
+
html = html.replace(tagPattern, cleanTag);
|
9264
|
+
html = html.replace(/^[ \t]+/mg, '');
|
9265
|
+
return html;
|
9266
|
+
}
|
9267
|
+
function buildKeepIdentity(element, mode) {
|
9268
|
+
if (mode === 'same-html') {
|
9269
|
+
return config.normalizeKeepHTML(element.outerHTML);
|
9270
|
+
}
|
9271
|
+
else if (mode === 'same-data') {
|
9272
|
+
return up.data(element);
|
9273
|
+
}
|
9274
|
+
else {
|
9275
|
+
return true;
|
9276
|
+
}
|
9277
|
+
}
|
9278
|
+
up.macro('[up-keep]', (element) => keepIdentity(element));
|
9279
|
+
function keepMode(element) {
|
9280
|
+
return e.booleanOrStringAttr(element, 'up-keep');
|
9281
|
+
}
|
9241
9282
|
function emitFragmentInserted(element) {
|
9242
9283
|
if (element.upInserted)
|
9243
9284
|
return;
|
@@ -9246,13 +9287,6 @@ up.fragment = (function () {
|
|
9246
9287
|
log: ['Inserted fragment %o', element],
|
9247
9288
|
});
|
9248
9289
|
}
|
9249
|
-
function emitFragmentKeep(keepPlan) {
|
9250
|
-
let { oldElement, newElement: newFragment, newData, renderOptions } = keepPlan;
|
9251
|
-
const log = ['Keeping fragment %o', oldElement];
|
9252
|
-
const callback = e.callbackAttr(keepPlan.oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });
|
9253
|
-
const event = up.event.build('up:fragment:keep', { newFragment, newData, renderOptions });
|
9254
|
-
return up.emit(oldElement, event, { log, callback });
|
9255
|
-
}
|
9256
9290
|
function emitFragmentDestroyed(fragment, options) {
|
9257
9291
|
var _a;
|
9258
9292
|
const log = (_a = options.log) !== null && _a !== void 0 ? _a : ['Destroyed fragment %o', fragment];
|
@@ -9712,8 +9746,8 @@ up.fragment = (function () {
|
|
9712
9746
|
}
|
9713
9747
|
up.on('up:framework:boot', function () {
|
9714
9748
|
const { documentElement } = document;
|
9715
|
-
documentElement.setAttribute('up-source', normalizeSource(location.href));
|
9716
9749
|
up.hello(documentElement);
|
9750
|
+
documentElement.setAttribute('up-source', normalizeSource(location.href));
|
9717
9751
|
if (!up.browser.canPushState()) {
|
9718
9752
|
return up.warn('Cannot push history changes. Next render pass with history will load a full page.');
|
9719
9753
|
}
|
@@ -9737,6 +9771,8 @@ up.fragment = (function () {
|
|
9737
9771
|
emitInserted: emitFragmentInserted,
|
9738
9772
|
emitDestroyed: emitFragmentDestroyed,
|
9739
9773
|
emitKeep: emitFragmentKeep,
|
9774
|
+
keepPlan: findKeepPlan,
|
9775
|
+
defaultNormalizeKeepHTML,
|
9740
9776
|
successKey,
|
9741
9777
|
failKey,
|
9742
9778
|
expandTargets,
|
@@ -9851,7 +9887,7 @@ up.viewport = (function () {
|
|
9851
9887
|
var _a;
|
9852
9888
|
return (_a = revealHashFn(...args)) === null || _a === void 0 ? void 0 : _a();
|
9853
9889
|
}
|
9854
|
-
function revealHashFn(hash
|
9890
|
+
function revealHashFn(hash, { strong, layer, origin, behavior = 'instant' } = {}) {
|
9855
9891
|
if (!hash)
|
9856
9892
|
return;
|
9857
9893
|
let match = firstHashTarget(hash, { layer, origin });
|
@@ -10158,7 +10194,7 @@ up.motion = (function () {
|
|
10158
10194
|
}
|
10159
10195
|
function animateNow(element, lastFrame, options) {
|
10160
10196
|
if (up.migrate.loaded)
|
10161
|
-
lastFrame = up.migrate.
|
10197
|
+
lastFrame = up.migrate.fixSetStyleProps(lastFrame);
|
10162
10198
|
options = Object.assign(Object.assign({}, options), { finishEvent: motionController.finishEvent });
|
10163
10199
|
const cssTransition = new up.CSSTransition(element, lastFrame, options);
|
10164
10200
|
return cssTransition.start();
|
@@ -10283,8 +10319,7 @@ up.motion = (function () {
|
|
10283
10319
|
}
|
10284
10320
|
function registerOpacityAnimation(name, from, to) {
|
10285
10321
|
namedAnimations.put(name, function (element, options) {
|
10286
|
-
element.style.opacity =
|
10287
|
-
e.setStyle(element, { opacity: from });
|
10322
|
+
element.style.opacity = from;
|
10288
10323
|
return animateNow(element, { opacity: to }, options);
|
10289
10324
|
});
|
10290
10325
|
}
|
@@ -10433,20 +10468,25 @@ up.network = (function () {
|
|
10433
10468
|
var _a, _b;
|
10434
10469
|
cache.expire((_a = responseOrError.expireCache) !== null && _a !== void 0 ? _a : false, { except: request });
|
10435
10470
|
cache.evict((_b = responseOrError.evictCache) !== null && _b !== void 0 ? _b : false, { except: request });
|
10436
|
-
let hasCacheEntry = cache.get(request);
|
10437
10471
|
let isResponse = responseOrError instanceof up.Response;
|
10438
10472
|
let isNetworkError = !isResponse;
|
10439
10473
|
let isSuccessResponse = isResponse && responseOrError.ok;
|
10440
10474
|
let isErrorResponse = isResponse && !responseOrError.ok;
|
10441
10475
|
let isEmptyResponse = isResponse && responseOrError.none;
|
10476
|
+
let redirectRequest = isResponse && responseOrError.redirectRequest;
|
10442
10477
|
if (isErrorResponse) {
|
10443
10478
|
cache.evict(request.url);
|
10444
10479
|
}
|
10445
10480
|
else if (isNetworkError || isEmptyResponse) {
|
10446
10481
|
cache.evict(request);
|
10447
10482
|
}
|
10448
|
-
else if (isSuccessResponse
|
10449
|
-
cache.
|
10483
|
+
else if (isSuccessResponse) {
|
10484
|
+
if (cache.get(request)) {
|
10485
|
+
cache.put(request);
|
10486
|
+
}
|
10487
|
+
if (redirectRequest && (redirectRequest.willCache() || cache.get(redirectRequest))) {
|
10488
|
+
cache.put(redirectRequest);
|
10489
|
+
}
|
10450
10490
|
}
|
10451
10491
|
});
|
10452
10492
|
}
|
@@ -10461,16 +10501,6 @@ up.network = (function () {
|
|
10461
10501
|
(_b = (_a = up.migrate).preprocessAbortArgs) === null || _b === void 0 ? void 0 : _b.call(_a, args);
|
10462
10502
|
queue.abort(...args);
|
10463
10503
|
}
|
10464
|
-
function registerAliasForRedirect(request, response) {
|
10465
|
-
if (request.cache && response.url && request.url !== response.url) {
|
10466
|
-
const newRequest = u.variant(request, {
|
10467
|
-
method: response.method,
|
10468
|
-
url: response.url,
|
10469
|
-
cacheRoute: null,
|
10470
|
-
});
|
10471
|
-
cache.alias(request, newRequest);
|
10472
|
-
}
|
10473
|
-
}
|
10474
10504
|
function isSafeMethod(method) {
|
10475
10505
|
return u.contains(['GET', 'OPTIONS', 'HEAD'], u.normalizeMethod(method));
|
10476
10506
|
}
|
@@ -10492,7 +10522,6 @@ up.network = (function () {
|
|
10492
10522
|
isSafeMethod,
|
10493
10523
|
config,
|
10494
10524
|
abort: abortRequests,
|
10495
|
-
registerAliasForRedirect,
|
10496
10525
|
queue,
|
10497
10526
|
loadPage,
|
10498
10527
|
};
|
@@ -11107,6 +11136,7 @@ up.form = (function () {
|
|
11107
11136
|
watchInputDelay: 0,
|
11108
11137
|
watchChangeEvents: ['change'],
|
11109
11138
|
watchableEvents: ['input', 'change'],
|
11139
|
+
arrayParam: (name) => name.endsWith('[]'),
|
11110
11140
|
}));
|
11111
11141
|
function fieldSelector(suffix = '') {
|
11112
11142
|
return config.fieldSelectors.map((field) => field + suffix).join();
|
@@ -11189,6 +11219,8 @@ up.form = (function () {
|
|
11189
11219
|
parser.string('url');
|
11190
11220
|
parser.string('method', { normalize: u.normalizeMethod });
|
11191
11221
|
parser.boolean('batch', { default: config.validateBatch });
|
11222
|
+
parser.json('params');
|
11223
|
+
parser.json('headers');
|
11192
11224
|
parser.include(watchOptions, { defaults: { event: 'change' } });
|
11193
11225
|
return options;
|
11194
11226
|
}
|
@@ -11255,8 +11287,7 @@ up.form = (function () {
|
|
11255
11287
|
options.method || (options.method = submitButton.getAttribute('formmethod'));
|
11256
11288
|
options.url || (options.url = submitButton.getAttribute('formaction'));
|
11257
11289
|
}
|
11258
|
-
params.
|
11259
|
-
options.params = params;
|
11290
|
+
options.params = up.Params.merge(params, options.params);
|
11260
11291
|
parser.string('url', { attr: 'action', default: up.fragment.source(form) });
|
11261
11292
|
parser.string('method', {
|
11262
11293
|
attr: ['up-method', 'data-method', 'method'],
|
@@ -11350,10 +11381,10 @@ up.form = (function () {
|
|
11350
11381
|
function trackFields(...args) {
|
11351
11382
|
let [root, { guard }, callback] = u.args(args, 'val', 'options', 'callback');
|
11352
11383
|
let filter = function (fields) {
|
11353
|
-
let
|
11384
|
+
let region = getRegion(root);
|
11354
11385
|
return u.filter(fields, function (field) {
|
11355
|
-
return (root ===
|
11356
|
-
&& (
|
11386
|
+
return (root === region || root.contains(field))
|
11387
|
+
&& (getRegion(field) === region)
|
11357
11388
|
&& (!guard || guard(field));
|
11358
11389
|
});
|
11359
11390
|
};
|
@@ -11430,29 +11461,38 @@ up.status = (function () {
|
|
11430
11461
|
noNavSelectors: ['[up-nav=false]'],
|
11431
11462
|
}));
|
11432
11463
|
let namedPreviewFns = new up.Registry('preview');
|
11433
|
-
function reset() {
|
11434
|
-
up.layer.root.feedbackLocation = null;
|
11435
|
-
}
|
11436
11464
|
const SELECTOR_LINK = 'a, [up-href]';
|
11437
11465
|
function linkCurrentURLs(link) {
|
11438
11466
|
return link.upCurrentURLs || (link.upCurrentURLs = new up.LinkCurrentURLs(link));
|
11439
11467
|
}
|
11440
|
-
function
|
11441
|
-
|
11442
|
-
let
|
11443
|
-
|
11444
|
-
|
11445
|
-
|
11446
|
-
|
11447
|
-
|
11448
|
-
for (let
|
11449
|
-
link.
|
11468
|
+
function getNavLocations(nav) {
|
11469
|
+
let layerRef = e.attr(nav, 'up-layer') || 'origin';
|
11470
|
+
let layers = up.layer.getAll(layerRef, { origin: nav });
|
11471
|
+
return u.compact(layers.map(getMatchableLayerLocation));
|
11472
|
+
}
|
11473
|
+
function updateNav(nav, links, { newLinks, anyLocationChanged }) {
|
11474
|
+
let currentLocations = (!anyLocationChanged && nav.upNavLocations) || getNavLocations(nav);
|
11475
|
+
if (newLinks || !u.isEqual(nav.upNavLocations, currentLocations)) {
|
11476
|
+
for (let link of links) {
|
11477
|
+
const isCurrent = linkCurrentURLs(link).isAnyCurrent(currentLocations);
|
11478
|
+
for (let currentClass of config.currentClasses) {
|
11479
|
+
link.classList.toggle(currentClass, isCurrent);
|
11480
|
+
}
|
11481
|
+
e.setAttrPresence(link, 'aria-current', 'page', isCurrent);
|
11450
11482
|
}
|
11451
|
-
|
11483
|
+
nav.upNavLocations = currentLocations;
|
11484
|
+
}
|
11485
|
+
}
|
11486
|
+
function updateNavsAround(root, opts) {
|
11487
|
+
const navSelector = config.selector('navSelectors');
|
11488
|
+
const fullNavs = e.around(root, navSelector);
|
11489
|
+
for (let fullNav of fullNavs) {
|
11490
|
+
let links = e.subtree(fullNav, SELECTOR_LINK);
|
11491
|
+
updateNav(fullNav, links, opts);
|
11452
11492
|
}
|
11453
11493
|
}
|
11454
11494
|
function getMatchableLayerLocation(layer) {
|
11455
|
-
return
|
11495
|
+
return u.matchableURL(layer.location);
|
11456
11496
|
}
|
11457
11497
|
function findActivatableArea(element) {
|
11458
11498
|
return e.ancestor(element, SELECTOR_LINK) || element;
|
@@ -11536,30 +11576,12 @@ up.status = (function () {
|
|
11536
11576
|
parser.string('placeholder');
|
11537
11577
|
return options;
|
11538
11578
|
}
|
11539
|
-
function updateLayerIfLocationChanged(layer) {
|
11540
|
-
const processedLocation = layer.feedbackLocation;
|
11541
|
-
const layerLocation = getMatchableLayerLocation(layer.location);
|
11542
|
-
if (!processedLocation || (processedLocation !== layerLocation)) {
|
11543
|
-
layer.feedbackLocation = layerLocation;
|
11544
|
-
updateFragment(layer.element, { layer });
|
11545
|
-
}
|
11546
|
-
}
|
11547
|
-
function onBrowserLocationChanged() {
|
11548
|
-
const frontLayer = up.layer.front;
|
11549
|
-
if (frontLayer.showsLiveHistory()) {
|
11550
|
-
updateLayerIfLocationChanged(frontLayer);
|
11551
|
-
}
|
11552
|
-
}
|
11553
|
-
up.on('up:location:changed', (_event) => {
|
11554
|
-
onBrowserLocationChanged();
|
11555
|
-
});
|
11556
11579
|
up.on('up:fragment:compile', (_event, newFragment) => {
|
11557
|
-
|
11580
|
+
updateNavsAround(newFragment, { newLinks: true, anyLocationChanged: false });
|
11558
11581
|
});
|
11559
|
-
up.on('up:layer:location:changed', (
|
11560
|
-
|
11582
|
+
up.on('up:layer:location:changed up:layer:opened up:layer:dismissed up:layer:accepted', () => {
|
11583
|
+
updateNavsAround(document.body, { newLinks: false, anyLocationChanged: true });
|
11561
11584
|
});
|
11562
|
-
up.on('up:framework:reset', reset);
|
11563
11585
|
return {
|
11564
11586
|
config,
|
11565
11587
|
preview: namedPreviewFns.put,
|
@@ -11706,8 +11728,7 @@ up.radio = (function () {
|
|
11706
11728
|
/******/ }
|
11707
11729
|
/******/
|
11708
11730
|
/************************************************************************/
|
11709
|
-
|
11710
|
-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
11731
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
11711
11732
|
(() => {
|
11712
11733
|
__webpack_require__(1);
|
11713
11734
|
__webpack_require__(2);
|