unpoly-rails 3.10.0.rc1 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly.es6.js +47 -49
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +44 -48
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/change/field_definition.rb +12 -4
- data/lib/unpoly/rails/change.rb +26 -11
- data/lib/unpoly/rails/util.rb +8 -0
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +5 -5
data/assets/unpoly/unpoly.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/***/ (() => {
|
6
6
|
|
7
7
|
window.up = {
|
8
|
-
version: '3.10.0
|
8
|
+
version: '3.10.0'
|
9
9
|
};
|
10
10
|
|
11
11
|
|
@@ -2212,18 +2212,16 @@ up.RenderJob = (_a = class RenderJob {
|
|
2212
2212
|
}
|
2213
2213
|
}
|
2214
2214
|
_getChange() {
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2215
|
+
let handleAbort = u.memoize((request) => this._handleAbortOption(request));
|
2216
|
+
let renderOptions = { ...this.options, handleAbort };
|
2217
|
+
if (renderOptions.url) {
|
2218
|
+
return new up.Change.FromURL(renderOptions);
|
2219
|
+
}
|
2220
|
+
else if (renderOptions.response) {
|
2221
|
+
return new up.Change.FromResponse(renderOptions);
|
2218
2222
|
}
|
2219
2223
|
else {
|
2220
|
-
|
2221
|
-
if (this.options.response) {
|
2222
|
-
return new up.Change.FromResponse({ ...this.options, onRender });
|
2223
|
-
}
|
2224
|
-
else {
|
2225
|
-
return new up.Change.FromContent({ ...this.options, onRender });
|
2226
|
-
}
|
2224
|
+
return new up.Change.FromContent(renderOptions);
|
2227
2225
|
}
|
2228
2226
|
}
|
2229
2227
|
_emitGuardEvent() {
|
@@ -2928,16 +2926,13 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2928
2926
|
up.network.loadPage(this.options);
|
2929
2927
|
return u.unresolvablePromise();
|
2930
2928
|
}
|
2931
|
-
this.request = up.request(this._getRequestAttrs());
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
this.
|
2936
|
-
|
2937
|
-
|
2938
|
-
_onRequestProcessed() {
|
2939
|
-
this.options.onRequestProcessed?.(this.request);
|
2940
|
-
this.request.runPreviews(this.options);
|
2929
|
+
let request = this.request = up.request(this._getRequestAttrs());
|
2930
|
+
this.options.onRequestKnown?.(request);
|
2931
|
+
if (this.options.preload)
|
2932
|
+
return request;
|
2933
|
+
this.options.handleAbort?.(request);
|
2934
|
+
request.runPreviews(this.options);
|
2935
|
+
return await u.always(request, responseOrError => this._onRequestSettled(responseOrError));
|
2941
2936
|
}
|
2942
2937
|
_newPageReason() {
|
2943
2938
|
if (u.isCrossOrigin(this.options.url)) {
|
@@ -2954,7 +2949,6 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2954
2949
|
...this.options,
|
2955
2950
|
...successAttrs,
|
2956
2951
|
...u.withRenamedKeys(failAttrs, up.fragment.failKey),
|
2957
|
-
onProcessed: this._onRequestProcessed.bind(this),
|
2958
2952
|
};
|
2959
2953
|
}
|
2960
2954
|
getPreflightProps() {
|
@@ -3203,7 +3197,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3203
3197
|
if (assets) {
|
3204
3198
|
up.script.assertAssetsOK(assets, plan.options);
|
3205
3199
|
}
|
3206
|
-
this.options.
|
3200
|
+
this.options.handleAbort?.(null);
|
3207
3201
|
}
|
3208
3202
|
_getResponseDoc() {
|
3209
3203
|
if (this._preflight)
|
@@ -5534,12 +5528,13 @@ up.LinkFollowIntent = class LinkFollowIntent {
|
|
5534
5528
|
constructor(link, callback) {
|
5535
5529
|
this._link = link;
|
5536
5530
|
this._callback = callback;
|
5531
|
+
this._lastRequest = null;
|
5537
5532
|
this._on('mouseenter mousedown touchstart', (event) => this._scheduleCallback(event));
|
5538
5533
|
this._on('mouseleave', () => this._unscheduleCallback());
|
5539
5534
|
up.fragment.onAborted(this._link, () => this._unscheduleCallback());
|
5540
5535
|
}
|
5541
|
-
_on(eventType,
|
5542
|
-
up.on(this._link, eventType, { passive: true },
|
5536
|
+
_on(eventType, fn) {
|
5537
|
+
up.on(this._link, eventType, { passive: true }, fn);
|
5543
5538
|
}
|
5544
5539
|
_scheduleCallback(event) {
|
5545
5540
|
if (!up.link.shouldFollowEvent(event, this._link))
|
@@ -5556,14 +5551,16 @@ up.LinkFollowIntent = class LinkFollowIntent {
|
|
5556
5551
|
}
|
5557
5552
|
_unscheduleCallback() {
|
5558
5553
|
clearTimeout(this._timer);
|
5559
|
-
|
5554
|
+
if (this._lastRequest?.background)
|
5555
|
+
this._lastRequest.abort();
|
5556
|
+
this._lastRequest = null;
|
5560
5557
|
}
|
5561
5558
|
_parseDelay() {
|
5562
5559
|
return e.numberAttr(this._link, 'up-preload-delay') ?? up.link.config.preloadDelay;
|
5563
5560
|
}
|
5564
5561
|
_runCallback(event) {
|
5565
5562
|
up.log.putsEvent(event);
|
5566
|
-
|
5563
|
+
this._callback({ onRequestKnown: (request) => this._lastRequest = request });
|
5567
5564
|
}
|
5568
5565
|
};
|
5569
5566
|
|
@@ -5680,17 +5677,15 @@ up.NonceableCallback = class NonceableCallback {
|
|
5680
5677
|
return new this(match[3], match[2]);
|
5681
5678
|
}
|
5682
5679
|
toFunction(...argNames) {
|
5683
|
-
let
|
5684
|
-
if (!/\b(;|return|throw)\b/.test(scriptExpression))
|
5685
|
-
scriptExpression = `return ${scriptExpression}`;
|
5680
|
+
let script = this.script;
|
5686
5681
|
if (this.nonce) {
|
5687
5682
|
let callbackThis = this;
|
5688
5683
|
return function (...args) {
|
5689
|
-
return callbackThis._runAsNoncedFunction(
|
5684
|
+
return callbackThis._runAsNoncedFunction(script, this, argNames, args);
|
5690
5685
|
};
|
5691
5686
|
}
|
5692
5687
|
else {
|
5693
|
-
return new Function(...argNames,
|
5688
|
+
return new Function(...argNames, script);
|
5694
5689
|
}
|
5695
5690
|
}
|
5696
5691
|
toString() {
|
@@ -8059,7 +8054,10 @@ up.protocol = (function () {
|
|
8059
8054
|
return u.normalizeMethod(up.browser.popCookie('_up_method'));
|
8060
8055
|
});
|
8061
8056
|
function locationFromXHR(xhr) {
|
8062
|
-
|
8057
|
+
let location = extractHeader(xhr, 'location') || xhr.responseURL;
|
8058
|
+
if (location) {
|
8059
|
+
return u.normalizeURL(location);
|
8060
|
+
}
|
8063
8061
|
}
|
8064
8062
|
const config = new up.Config(() => ({
|
8065
8063
|
methodParam: '_method',
|
@@ -8234,7 +8232,6 @@ up.script = (function () {
|
|
8234
8232
|
'up-on-finished',
|
8235
8233
|
'up-on-error',
|
8236
8234
|
'up-on-offline',
|
8237
|
-
'up-placeholder',
|
8238
8235
|
],
|
8239
8236
|
scriptSelectors: [
|
8240
8237
|
'script:not([type])',
|
@@ -9004,7 +9001,7 @@ up.fragment = (function () {
|
|
9004
9001
|
continue;
|
9005
9002
|
let placement = defaultPlacement;
|
9006
9003
|
let maybe = defaultMaybe;
|
9007
|
-
selector = selector.replace(/\b::?(before|after)\b/, (_match, customPlacement) => {
|
9004
|
+
selector = selector.replace(/\b::?(before|after|content)\b/, (_match, customPlacement) => {
|
9008
9005
|
placement = customPlacement;
|
9009
9006
|
return '';
|
9010
9007
|
});
|
@@ -9468,7 +9465,7 @@ up.viewport = (function () {
|
|
9468
9465
|
function firstHashTarget(hash, options = {}) {
|
9469
9466
|
if (hash = pureHash(hash)) {
|
9470
9467
|
const selector = [
|
9471
|
-
e.
|
9468
|
+
e.idSelector(hash),
|
9472
9469
|
'a' + e.attrSelector('name', hash)
|
9473
9470
|
].join();
|
9474
9471
|
return f.get(selector, options);
|
@@ -10488,7 +10485,7 @@ up.link = (function () {
|
|
10488
10485
|
return follow(link, forcedOptions, { defaults });
|
10489
10486
|
}
|
10490
10487
|
up.attribute('up-defer', { defaultValue: 'insert' }, function (link, condition) {
|
10491
|
-
let doLoad = () => up.error.muteUncriticalRejection(loadDeferred(link));
|
10488
|
+
let doLoad = (options) => up.error.muteUncriticalRejection(loadDeferred(link, options));
|
10492
10489
|
onLoadCondition(condition, link, doLoad);
|
10493
10490
|
});
|
10494
10491
|
up.on('up:click', config.selectorFn('followSelectors'), function (event, link) {
|
@@ -10511,7 +10508,7 @@ up.link = (function () {
|
|
10511
10508
|
});
|
10512
10509
|
up.compiler(config.selectorFn('preloadSelectors'), function (link) {
|
10513
10510
|
if (!isPreloadDisabled(link)) {
|
10514
|
-
let doPreload = () => up.error.muteUncriticalRejection(preload(link));
|
10511
|
+
let doPreload = (options) => up.error.muteUncriticalRejection(preload(link, options));
|
10515
10512
|
let condition = e.booleanOrStringAttr(link, 'up-preload');
|
10516
10513
|
if (condition === true || u.isUndefined(condition))
|
10517
10514
|
condition = 'hover';
|
@@ -10650,16 +10647,10 @@ up.form = (function () {
|
|
10650
10647
|
else {
|
10651
10648
|
control.disabled = true;
|
10652
10649
|
}
|
10653
|
-
return () => {
|
10654
|
-
control.disabled = false;
|
10655
|
-
if (focusFallback && document.activeElement === focusFallback && control.isConnected) {
|
10656
|
-
up.focus(control, { preventScroll: true });
|
10657
|
-
}
|
10658
|
-
};
|
10650
|
+
return () => { control.disabled = false; };
|
10659
10651
|
}
|
10660
10652
|
function getDisableContainers(disable, origin) {
|
10661
|
-
let
|
10662
|
-
let originScope = () => getScope(givenOrigin());
|
10653
|
+
let originScope = () => getScope(origin);
|
10663
10654
|
if (disable === true) {
|
10664
10655
|
return [originScope()];
|
10665
10656
|
}
|
@@ -10848,8 +10839,13 @@ up.form = (function () {
|
|
10848
10839
|
const element = up.fragment.get(elementOrSelector, options);
|
10849
10840
|
return element.form || element.closest('form');
|
10850
10841
|
}
|
10851
|
-
function getScope(
|
10852
|
-
|
10842
|
+
function getScope(origin, options) {
|
10843
|
+
if (origin) {
|
10844
|
+
return getForm(origin, options) || up.layer.get(origin).element;
|
10845
|
+
}
|
10846
|
+
else {
|
10847
|
+
return up.layer.current.element;
|
10848
|
+
}
|
10853
10849
|
}
|
10854
10850
|
function focusedField() {
|
10855
10851
|
return u.presence(document.activeElement, isField);
|