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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d889aec4a6495a22b4f474a1cb3a066360a1838183139de2a9a2aa6f9d8acf1
4
- data.tar.gz: 89d0db20ed986710ddb923d28fd1d5cf7fae0089a147d8f11f8d67679ad17647
3
+ metadata.gz: 70b475102f62b95687296c3218604fecef3c49e38b4bfdf376dbecf7c90d76f5
4
+ data.tar.gz: c0bbad9322300f46e3142bacaa227cb580a787c7156565eceed738a8df446c16
5
5
  SHA512:
6
- metadata.gz: 72e44c3a6a9377725f69b691e2a079c7b9c19a938964f499050917a258f68cbd91c423a9505afb5303c88ccd92984eedc1052c97327b3217e8769e1bf2d1b45a
7
- data.tar.gz: e5e70620751f7421bea189bca4efcf1c092b12e01336041f5dbeed68953768012bfbe943f85fd82302318b2d16be5e27249ce54064bec7393601a6706eac27a8
6
+ metadata.gz: e8d2f624fdb7462162f90df5e98131c7f4941fa7911be886775dfd3fb56efe68ae7c0d590af9c7eb3bdeabc6ae95f387570bb98250423d5d7e9ce58a4f966acd
7
+ data.tar.gz: 6c403420b54d7044f6bf30fdf4b0bbd9ff5de9a8bb1b6c668bfda25a94eb64ad0553af0c0114ce4dbcd83cfdad7c29fe3558150f7ed0f42720d4f7f09582b3dc
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.10.0-rc1'
8
+ version: '3.10.0'
9
9
  };
10
10
 
11
11
 
@@ -2230,18 +2230,16 @@ up.RenderJob = (_a = class RenderJob {
2230
2230
  });
2231
2231
  }
2232
2232
  _getChange() {
2233
- if (this.options.url) {
2234
- let onRequestProcessed = (request) => this._handleAbortOption(request);
2235
- return new up.Change.FromURL(Object.assign(Object.assign({}, this.options), { onRequestProcessed }));
2233
+ let handleAbort = u.memoize((request) => this._handleAbortOption(request));
2234
+ let renderOptions = Object.assign(Object.assign({}, this.options), { handleAbort });
2235
+ if (renderOptions.url) {
2236
+ return new up.Change.FromURL(renderOptions);
2237
+ }
2238
+ else if (renderOptions.response) {
2239
+ return new up.Change.FromResponse(renderOptions);
2236
2240
  }
2237
2241
  else {
2238
- let onRender = () => this._handleAbortOption(null);
2239
- if (this.options.response) {
2240
- return new up.Change.FromResponse(Object.assign(Object.assign({}, this.options), { onRender }));
2241
- }
2242
- else {
2243
- return new up.Change.FromContent(Object.assign(Object.assign({}, this.options), { onRender }));
2244
- }
2242
+ return new up.Change.FromContent(renderOptions);
2245
2243
  }
2246
2244
  }
2247
2245
  _emitGuardEvent() {
@@ -2955,6 +2953,7 @@ var _a;
2955
2953
  const u = up.util;
2956
2954
  up.Change.FromURL = (_a = class FromURL extends up.Change {
2957
2955
  execute() {
2956
+ var _b, _c, _d, _e;
2958
2957
  return __awaiter(this, void 0, void 0, function* () {
2959
2958
  let newPageReason = this._newPageReason();
2960
2959
  if (newPageReason) {
@@ -2962,19 +2961,15 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2962
2961
  up.network.loadPage(this.options);
2963
2962
  return u.unresolvablePromise();
2964
2963
  }
2965
- this.request = up.request(this._getRequestAttrs());
2966
- if (this.options.preload) {
2967
- return this.request;
2968
- }
2969
- this._onRequestProcessed();
2970
- return yield u.always(this.request, responseOrError => this._onRequestSettled(responseOrError));
2964
+ let request = this.request = up.request(this._getRequestAttrs());
2965
+ (_c = (_b = this.options).onRequestKnown) === null || _c === void 0 ? void 0 : _c.call(_b, request);
2966
+ if (this.options.preload)
2967
+ return request;
2968
+ (_e = (_d = this.options).handleAbort) === null || _e === void 0 ? void 0 : _e.call(_d, request);
2969
+ request.runPreviews(this.options);
2970
+ return yield u.always(request, responseOrError => this._onRequestSettled(responseOrError));
2971
2971
  });
2972
2972
  }
2973
- _onRequestProcessed() {
2974
- var _b, _c;
2975
- (_c = (_b = this.options).onRequestProcessed) === null || _c === void 0 ? void 0 : _c.call(_b, this.request);
2976
- this.request.runPreviews(this.options);
2977
- }
2978
2973
  _newPageReason() {
2979
2974
  if (u.isCrossOrigin(this.options.url)) {
2980
2975
  return 'Loading cross-origin content in new page';
@@ -2986,7 +2981,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2986
2981
  _getRequestAttrs() {
2987
2982
  const successAttrs = this._preflightPropsForRenderOptions(this.options);
2988
2983
  const failAttrs = this._preflightPropsForRenderOptions(this.deriveFailOptions(), { optional: true });
2989
- return Object.assign(Object.assign(Object.assign(Object.assign({}, this.options), successAttrs), u.withRenamedKeys(failAttrs, up.fragment.failKey)), { onProcessed: this._onRequestProcessed.bind(this) });
2984
+ return Object.assign(Object.assign(Object.assign({}, this.options), successAttrs), u.withRenamedKeys(failAttrs, up.fragment.failKey));
2990
2985
  }
2991
2986
  getPreflightProps() {
2992
2987
  return this._getRequestAttrs();
@@ -3233,7 +3228,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3233
3228
  if (assets) {
3234
3229
  up.script.assertAssetsOK(assets, plan.options);
3235
3230
  }
3236
- (_c = (_b = this.options).onRender) === null || _c === void 0 ? void 0 : _c.call(_b);
3231
+ (_c = (_b = this.options).handleAbort) === null || _c === void 0 ? void 0 : _c.call(_b, null);
3237
3232
  }
3238
3233
  _getResponseDoc() {
3239
3234
  var _b, _c;
@@ -5634,12 +5629,13 @@ up.LinkFollowIntent = class LinkFollowIntent {
5634
5629
  constructor(link, callback) {
5635
5630
  this._link = link;
5636
5631
  this._callback = callback;
5632
+ this._lastRequest = null;
5637
5633
  this._on('mouseenter mousedown touchstart', (event) => this._scheduleCallback(event));
5638
5634
  this._on('mouseleave', () => this._unscheduleCallback());
5639
5635
  up.fragment.onAborted(this._link, () => this._unscheduleCallback());
5640
5636
  }
5641
- _on(eventType, callback) {
5642
- up.on(this._link, eventType, { passive: true }, callback);
5637
+ _on(eventType, fn) {
5638
+ up.on(this._link, eventType, { passive: true }, fn);
5643
5639
  }
5644
5640
  _scheduleCallback(event) {
5645
5641
  if (!up.link.shouldFollowEvent(event, this._link))
@@ -5655,8 +5651,11 @@ up.LinkFollowIntent = class LinkFollowIntent {
5655
5651
  }
5656
5652
  }
5657
5653
  _unscheduleCallback() {
5654
+ var _a;
5658
5655
  clearTimeout(this._timer);
5659
- up.network.abort((request) => (request.origin === this._link) && request.background);
5656
+ if ((_a = this._lastRequest) === null || _a === void 0 ? void 0 : _a.background)
5657
+ this._lastRequest.abort();
5658
+ this._lastRequest = null;
5660
5659
  }
5661
5660
  _parseDelay() {
5662
5661
  var _a;
@@ -5664,7 +5663,7 @@ up.LinkFollowIntent = class LinkFollowIntent {
5664
5663
  }
5665
5664
  _runCallback(event) {
5666
5665
  up.log.putsEvent(event);
5667
- up.error.muteUncriticalRejection(this._callback());
5666
+ this._callback({ onRequestKnown: (request) => this._lastRequest = request });
5668
5667
  }
5669
5668
  };
5670
5669
 
@@ -5794,17 +5793,15 @@ up.NonceableCallback = class NonceableCallback {
5794
5793
  return new this(match[3], match[2]);
5795
5794
  }
5796
5795
  toFunction(...argNames) {
5797
- let scriptExpression = this.script;
5798
- if (!/\b(;|return|throw)\b/.test(scriptExpression))
5799
- scriptExpression = `return ${scriptExpression}`;
5796
+ let script = this.script;
5800
5797
  if (this.nonce) {
5801
5798
  let callbackThis = this;
5802
5799
  return function (...args) {
5803
- return callbackThis._runAsNoncedFunction(scriptExpression, this, argNames, args);
5800
+ return callbackThis._runAsNoncedFunction(script, this, argNames, args);
5804
5801
  };
5805
5802
  }
5806
5803
  else {
5807
- return new Function(...argNames, scriptExpression);
5804
+ return new Function(...argNames, script);
5808
5805
  }
5809
5806
  }
5810
5807
  toString() {
@@ -8203,7 +8200,10 @@ up.protocol = (function () {
8203
8200
  return u.normalizeMethod(up.browser.popCookie('_up_method'));
8204
8201
  });
8205
8202
  function locationFromXHR(xhr) {
8206
- return extractHeader(xhr, 'location') || xhr.responseURL;
8203
+ let location = extractHeader(xhr, 'location') || xhr.responseURL;
8204
+ if (location) {
8205
+ return u.normalizeURL(location);
8206
+ }
8207
8207
  }
8208
8208
  const config = new up.Config(() => ({
8209
8209
  methodParam: '_method',
@@ -8378,7 +8378,6 @@ up.script = (function () {
8378
8378
  'up-on-finished',
8379
8379
  'up-on-error',
8380
8380
  'up-on-offline',
8381
- 'up-placeholder',
8382
8381
  ],
8383
8382
  scriptSelectors: [
8384
8383
  'script:not([type])',
@@ -9150,7 +9149,7 @@ up.fragment = (function () {
9150
9149
  continue;
9151
9150
  let placement = defaultPlacement;
9152
9151
  let maybe = defaultMaybe;
9153
- selector = selector.replace(/\b::?(before|after)\b/, (_match, customPlacement) => {
9152
+ selector = selector.replace(/\b::?(before|after|content)\b/, (_match, customPlacement) => {
9154
9153
  placement = customPlacement;
9155
9154
  return '';
9156
9155
  });
@@ -9610,7 +9609,7 @@ up.viewport = (function () {
9610
9609
  function firstHashTarget(hash, options = {}) {
9611
9610
  if (hash = pureHash(hash)) {
9612
9611
  const selector = [
9613
- e.attrSelector('id', hash),
9612
+ e.idSelector(hash),
9614
9613
  'a' + e.attrSelector('name', hash)
9615
9614
  ].join();
9616
9615
  return f.get(selector, options);
@@ -10633,7 +10632,7 @@ up.link = (function () {
10633
10632
  return follow(link, forcedOptions, { defaults });
10634
10633
  }
10635
10634
  up.attribute('up-defer', { defaultValue: 'insert' }, function (link, condition) {
10636
- let doLoad = () => up.error.muteUncriticalRejection(loadDeferred(link));
10635
+ let doLoad = (options) => up.error.muteUncriticalRejection(loadDeferred(link, options));
10637
10636
  onLoadCondition(condition, link, doLoad);
10638
10637
  });
10639
10638
  up.on('up:click', config.selectorFn('followSelectors'), function (event, link) {
@@ -10653,7 +10652,7 @@ up.link = (function () {
10653
10652
  });
10654
10653
  up.compiler(config.selectorFn('preloadSelectors'), function (link) {
10655
10654
  if (!isPreloadDisabled(link)) {
10656
- let doPreload = () => up.error.muteUncriticalRejection(preload(link));
10655
+ let doPreload = (options) => up.error.muteUncriticalRejection(preload(link, options));
10657
10656
  let condition = e.booleanOrStringAttr(link, 'up-preload');
10658
10657
  if (condition === true || u.isUndefined(condition))
10659
10658
  condition = 'hover';
@@ -10790,16 +10789,10 @@ up.form = (function () {
10790
10789
  else {
10791
10790
  control.disabled = true;
10792
10791
  }
10793
- return () => {
10794
- control.disabled = false;
10795
- if (focusFallback && document.activeElement === focusFallback && control.isConnected) {
10796
- up.focus(control, { preventScroll: true });
10797
- }
10798
- };
10792
+ return () => { control.disabled = false; };
10799
10793
  }
10800
10794
  function getDisableContainers(disable, origin) {
10801
- let givenOrigin = () => origin || up.fail('Missing { origin }');
10802
- let originScope = () => getScope(givenOrigin());
10795
+ let originScope = () => getScope(origin);
10803
10796
  if (disable === true) {
10804
10797
  return [originScope()];
10805
10798
  }
@@ -10990,8 +10983,13 @@ up.form = (function () {
10990
10983
  const element = up.fragment.get(elementOrSelector, options);
10991
10984
  return element.form || element.closest('form');
10992
10985
  }
10993
- function getScope(element, options) {
10994
- return getForm(element, options) || up.layer.get(element).element;
10986
+ function getScope(origin, options) {
10987
+ if (origin) {
10988
+ return getForm(origin, options) || up.layer.get(origin).element;
10989
+ }
10990
+ else {
10991
+ return up.layer.current.element;
10992
+ }
10995
10993
  }
10996
10994
  function focusedField() {
10997
10995
  return u.presence(document.activeElement, isField);