unpoly-rails 3.10.0.rc1 → 3.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d889aec4a6495a22b4f474a1cb3a066360a1838183139de2a9a2aa6f9d8acf1
4
- data.tar.gz: 89d0db20ed986710ddb923d28fd1d5cf7fae0089a147d8f11f8d67679ad17647
3
+ metadata.gz: 37db81cf31bc9480ba80407d23344ca9e4bfad195071a655852da126d4f56097
4
+ data.tar.gz: d4c8ee2ec83656a6e419002eca43f52f9eaa0656b02fa64087826e18cefcb299
5
5
  SHA512:
6
- metadata.gz: 72e44c3a6a9377725f69b691e2a079c7b9c19a938964f499050917a258f68cbd91c423a9505afb5303c88ccd92984eedc1052c97327b3217e8769e1bf2d1b45a
7
- data.tar.gz: e5e70620751f7421bea189bca4efcf1c092b12e01336041f5dbeed68953768012bfbe943f85fd82302318b2d16be5e27249ce54064bec7393601a6706eac27a8
6
+ metadata.gz: b959922764b4dafdf7b1756effcd3673bc834f652383da79ee4cb90e34d987b27a15c79ca156e5ef0d0a59e664ef96639c8abbb3c6deb5951b7736eb4d484866
7
+ data.tar.gz: 7209ed9ae1f2253689db9ce1aa4db9ee520c7f7794d1b4bce9e4305c945ba367f72e1d1800f4379a0dbeb78aeb7aba304cd739e73f0bf8b6d669c81509c62e1f
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.10.0-rc1'
8
+ version: '3.10.2'
9
9
  };
10
10
 
11
11
 
@@ -639,8 +639,8 @@ up.util = (function () {
639
639
  });
640
640
  }
641
641
  }
642
- function delegatePromise(object, promiseProp) {
643
- return defineDelegates(object, ['then', 'catch', 'finally'], function () { return this[promiseProp]; });
642
+ function delegatePromise(object, targetProvider) {
643
+ return defineDelegates(object, ['then', 'catch', 'finally'], targetProvider);
644
644
  }
645
645
  function stringifyArg(arg, placeholder = '%o') {
646
646
  let string;
@@ -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() {
@@ -2282,7 +2280,7 @@ up.RenderJob = (_a = class RenderJob {
2282
2280
  }
2283
2281
  },
2284
2282
  (() => {
2285
- u.delegatePromise(_a.prototype, '_rendered');
2283
+ u.delegatePromise(_a.prototype, function () { return this._rendered; });
2286
2284
  u.memoizeMethod(_a.prototype, {
2287
2285
  _awaitFinished: true,
2288
2286
  _getChange: true,
@@ -2878,9 +2876,8 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
2878
2876
  this._history = (_b = options.history) !== null && _b !== void 0 ? _b : true;
2879
2877
  }
2880
2878
  execute() {
2881
- if (!this._layer.isOpen()) {
2882
- return Promise.resolve();
2883
- }
2879
+ if (!this._layer.isOpen())
2880
+ return;
2884
2881
  up.browser.assertConfirmed(this.options);
2885
2882
  if (this._emitCloseEvent().defaultPrevented && this._preventable) {
2886
2883
  throw new up.Aborted('Close event was prevented');
@@ -2930,10 +2927,13 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
2930
2927
  }
2931
2928
  _handleFocus(formerParent) {
2932
2929
  var _a;
2930
+ let hadFocus = this._layer.hasFocus();
2933
2931
  this._layer.overlayFocus.teardown();
2934
2932
  (_a = formerParent.overlayFocus) === null || _a === void 0 ? void 0 : _a.moveToFront();
2935
- let newFocusElement = this._layer.origin || formerParent.element;
2936
- up.focus(newFocusElement, { preventScroll: true });
2933
+ if (hadFocus) {
2934
+ let newFocusElement = this._layer.origin || formerParent.element;
2935
+ up.focus(newFocusElement, { preventScroll: true });
2936
+ }
2937
2937
  }
2938
2938
  };
2939
2939
 
@@ -2955,6 +2955,7 @@ var _a;
2955
2955
  const u = up.util;
2956
2956
  up.Change.FromURL = (_a = class FromURL extends up.Change {
2957
2957
  execute() {
2958
+ var _b, _c, _d, _e;
2958
2959
  return __awaiter(this, void 0, void 0, function* () {
2959
2960
  let newPageReason = this._newPageReason();
2960
2961
  if (newPageReason) {
@@ -2962,19 +2963,15 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2962
2963
  up.network.loadPage(this.options);
2963
2964
  return u.unresolvablePromise();
2964
2965
  }
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));
2966
+ let request = this.request = up.request(this._getRequestAttrs());
2967
+ (_c = (_b = this.options).onRequestKnown) === null || _c === void 0 ? void 0 : _c.call(_b, request);
2968
+ if (this.options.preload)
2969
+ return request;
2970
+ (_e = (_d = this.options).handleAbort) === null || _e === void 0 ? void 0 : _e.call(_d, request);
2971
+ request.runPreviews(this.options);
2972
+ return yield u.always(request, responseOrError => this._onRequestSettled(responseOrError));
2971
2973
  });
2972
2974
  }
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
2975
  _newPageReason() {
2979
2976
  if (u.isCrossOrigin(this.options.url)) {
2980
2977
  return 'Loading cross-origin content in new page';
@@ -2986,7 +2983,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2986
2983
  _getRequestAttrs() {
2987
2984
  const successAttrs = this._preflightPropsForRenderOptions(this.options);
2988
2985
  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) });
2986
+ return Object.assign(Object.assign(Object.assign({}, this.options), successAttrs), u.withRenamedKeys(failAttrs, up.fragment.failKey));
2990
2987
  }
2991
2988
  getPreflightProps() {
2992
2989
  return this._getRequestAttrs();
@@ -3233,7 +3230,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3233
3230
  if (assets) {
3234
3231
  up.script.assertAssetsOK(assets, plan.options);
3235
3232
  }
3236
- (_c = (_b = this.options).onRender) === null || _c === void 0 ? void 0 : _c.call(_b);
3233
+ (_c = (_b = this.options).handleAbort) === null || _c === void 0 ? void 0 : _c.call(_b, null);
3237
3234
  }
3238
3235
  _getResponseDoc() {
3239
3236
  var _b, _c;
@@ -4179,15 +4176,21 @@ up.FormValidator = class FormValidator {
4179
4176
  /***/ (() => {
4180
4177
 
4181
4178
  up.FocusCapsule = class FocusCapsule {
4182
- constructor(element, target, cursorProps) {
4179
+ constructor(element, target) {
4183
4180
  this._element = element;
4184
4181
  this._target = target;
4185
- this._cursorProps = cursorProps;
4182
+ this._cursorProps = up.viewport.copyCursorProps(this._element);
4186
4183
  }
4187
4184
  wasLost() {
4188
- return document.activeElement !== this._element;
4185
+ return document.activeElement !== this._element && !this._voided;
4186
+ }
4187
+ autoVoid() {
4188
+ up.on('focusin', { once: true }, () => this._voided = true);
4189
4189
  }
4190
4190
  restore(layer, focusOptions) {
4191
+ if (!this.wasLost()) {
4192
+ return false;
4193
+ }
4191
4194
  let rediscoveredElement = up.fragment.get(this._target, { layer });
4192
4195
  if (rediscoveredElement) {
4193
4196
  up.viewport.copyCursorProps(this._cursorProps, rediscoveredElement);
@@ -4202,8 +4205,7 @@ up.FocusCapsule = class FocusCapsule {
4202
4205
  let target = up.fragment.tryToTarget(focusedElement);
4203
4206
  if (!target)
4204
4207
  return;
4205
- const cursorProps = up.viewport.copyCursorProps(focusedElement);
4206
- return new this(focusedElement, target, cursorProps);
4208
+ return new this(focusedElement, target);
4207
4209
  }
4208
4210
  };
4209
4211
 
@@ -4379,9 +4381,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4379
4381
  }
4380
4382
  _restoreLostFocus() {
4381
4383
  var _a;
4382
- if (this._wasFocusLost()) {
4383
- return (_a = this.focusCapsule) === null || _a === void 0 ? void 0 : _a.restore(this.layer, PREVENT_SCROLL_OPTIONS);
4384
- }
4384
+ return (_a = this.focusCapsule) === null || _a === void 0 ? void 0 : _a.restore(this.layer, PREVENT_SCROLL_OPTIONS);
4385
4385
  }
4386
4386
  _restorePreviousFocusForLocation() {
4387
4387
  return up.viewport.restoreFocus({ layer: this.layer });
@@ -5634,12 +5634,13 @@ up.LinkFollowIntent = class LinkFollowIntent {
5634
5634
  constructor(link, callback) {
5635
5635
  this._link = link;
5636
5636
  this._callback = callback;
5637
+ this._lastRequest = null;
5637
5638
  this._on('mouseenter mousedown touchstart', (event) => this._scheduleCallback(event));
5638
5639
  this._on('mouseleave', () => this._unscheduleCallback());
5639
5640
  up.fragment.onAborted(this._link, () => this._unscheduleCallback());
5640
5641
  }
5641
- _on(eventType, callback) {
5642
- up.on(this._link, eventType, { passive: true }, callback);
5642
+ _on(eventType, fn) {
5643
+ up.on(this._link, eventType, { passive: true }, fn);
5643
5644
  }
5644
5645
  _scheduleCallback(event) {
5645
5646
  if (!up.link.shouldFollowEvent(event, this._link))
@@ -5655,8 +5656,11 @@ up.LinkFollowIntent = class LinkFollowIntent {
5655
5656
  }
5656
5657
  }
5657
5658
  _unscheduleCallback() {
5659
+ var _a;
5658
5660
  clearTimeout(this._timer);
5659
- up.network.abort((request) => (request.origin === this._link) && request.background);
5661
+ if ((_a = this._lastRequest) === null || _a === void 0 ? void 0 : _a.background)
5662
+ this._lastRequest.abort();
5663
+ this._lastRequest = null;
5660
5664
  }
5661
5665
  _parseDelay() {
5662
5666
  var _a;
@@ -5664,7 +5668,7 @@ up.LinkFollowIntent = class LinkFollowIntent {
5664
5668
  }
5665
5669
  _runCallback(event) {
5666
5670
  up.log.putsEvent(event);
5667
- up.error.muteUncriticalRejection(this._callback());
5671
+ this._callback({ onRequestKnown: (request) => this._lastRequest = request });
5668
5672
  }
5669
5673
  };
5670
5674
 
@@ -5794,17 +5798,15 @@ up.NonceableCallback = class NonceableCallback {
5794
5798
  return new this(match[3], match[2]);
5795
5799
  }
5796
5800
  toFunction(...argNames) {
5797
- let scriptExpression = this.script;
5798
- if (!/\b(;|return|throw)\b/.test(scriptExpression))
5799
- scriptExpression = `return ${scriptExpression}`;
5801
+ let script = this.script;
5800
5802
  if (this.nonce) {
5801
5803
  let callbackThis = this;
5802
5804
  return function (...args) {
5803
- return callbackThis._runAsNoncedFunction(scriptExpression, this, argNames, args);
5805
+ return callbackThis._runAsNoncedFunction(script, this, argNames, args);
5804
5806
  };
5805
5807
  }
5806
5808
  else {
5807
- return new Function(...argNames, scriptExpression);
5809
+ return new Function(...argNames, script);
5808
5810
  }
5809
5811
  }
5810
5812
  toString() {
@@ -6930,7 +6932,7 @@ up.Request = (_a = class Request extends up.Record {
6930
6932
  }
6931
6933
  },
6932
6934
  (() => {
6933
- u.delegatePromise(_a.prototype, '_deferred');
6935
+ u.delegatePromise(_a.prototype, function () { return this._deferred; });
6934
6936
  })(),
6935
6937
  _a);
6936
6938
 
@@ -7094,14 +7096,14 @@ up.Request.Cache = class Cache {
7094
7096
  _isUsable(request) {
7095
7097
  return request.age < up.network.config.cacheEvictAge;
7096
7098
  }
7097
- get _size() {
7099
+ get currentSize() {
7098
7100
  return this._requests.length;
7099
7101
  }
7100
7102
  get _capacity() {
7101
7103
  return up.network.config.cacheSize;
7102
7104
  }
7103
7105
  _limitSize() {
7104
- for (let i = 0; i < (this._size - this._capacity); i++) {
7106
+ for (let i = 0; i < (this.currentSize - this._capacity); i++) {
7105
7107
  this._delete(this._requests[0]);
7106
7108
  }
7107
7109
  }
@@ -8203,7 +8205,10 @@ up.protocol = (function () {
8203
8205
  return u.normalizeMethod(up.browser.popCookie('_up_method'));
8204
8206
  });
8205
8207
  function locationFromXHR(xhr) {
8206
- return extractHeader(xhr, 'location') || xhr.responseURL;
8208
+ let location = extractHeader(xhr, 'location') || xhr.responseURL;
8209
+ if (location) {
8210
+ return u.normalizeURL(location);
8211
+ }
8207
8212
  }
8208
8213
  const config = new up.Config(() => ({
8209
8214
  methodParam: '_method',
@@ -8378,7 +8383,6 @@ up.script = (function () {
8378
8383
  'up-on-finished',
8379
8384
  'up-on-error',
8380
8385
  'up-on-offline',
8381
- 'up-placeholder',
8382
8386
  ],
8383
8387
  scriptSelectors: [
8384
8388
  'script:not([type])',
@@ -9150,7 +9154,7 @@ up.fragment = (function () {
9150
9154
  continue;
9151
9155
  let placement = defaultPlacement;
9152
9156
  let maybe = defaultMaybe;
9153
- selector = selector.replace(/\b::?(before|after)\b/, (_match, customPlacement) => {
9157
+ selector = selector.replace(/\b::?(before|after|content)\b/, (_match, customPlacement) => {
9154
9158
  placement = customPlacement;
9155
9159
  return '';
9156
9160
  });
@@ -9610,7 +9614,7 @@ up.viewport = (function () {
9610
9614
  function firstHashTarget(hash, options = {}) {
9611
9615
  if (hash = pureHash(hash)) {
9612
9616
  const selector = [
9613
- e.attrSelector('id', hash),
9617
+ e.idSelector(hash),
9614
9618
  'a' + e.attrSelector('name', hash)
9615
9619
  ].join();
9616
9620
  return f.get(selector, options);
@@ -10633,7 +10637,7 @@ up.link = (function () {
10633
10637
  return follow(link, forcedOptions, { defaults });
10634
10638
  }
10635
10639
  up.attribute('up-defer', { defaultValue: 'insert' }, function (link, condition) {
10636
- let doLoad = () => up.error.muteUncriticalRejection(loadDeferred(link));
10640
+ let doLoad = (options) => up.error.muteUncriticalRejection(loadDeferred(link, options));
10637
10641
  onLoadCondition(condition, link, doLoad);
10638
10642
  });
10639
10643
  up.on('up:click', config.selectorFn('followSelectors'), function (event, link) {
@@ -10653,7 +10657,7 @@ up.link = (function () {
10653
10657
  });
10654
10658
  up.compiler(config.selectorFn('preloadSelectors'), function (link) {
10655
10659
  if (!isPreloadDisabled(link)) {
10656
- let doPreload = () => up.error.muteUncriticalRejection(preload(link));
10660
+ let doPreload = (options) => up.error.muteUncriticalRejection(preload(link, options));
10657
10661
  let condition = e.booleanOrStringAttr(link, 'up-preload');
10658
10662
  if (condition === true || u.isUndefined(condition))
10659
10663
  condition = 'hover';
@@ -10790,16 +10794,10 @@ up.form = (function () {
10790
10794
  else {
10791
10795
  control.disabled = true;
10792
10796
  }
10793
- return () => {
10794
- control.disabled = false;
10795
- if (focusFallback && document.activeElement === focusFallback && control.isConnected) {
10796
- up.focus(control, { preventScroll: true });
10797
- }
10798
- };
10797
+ return () => { control.disabled = false; };
10799
10798
  }
10800
10799
  function getDisableContainers(disable, origin) {
10801
- let givenOrigin = () => origin || up.fail('Missing { origin }');
10802
- let originScope = () => getScope(givenOrigin());
10800
+ let originScope = () => getScope(origin);
10803
10801
  if (disable === true) {
10804
10802
  return [originScope()];
10805
10803
  }
@@ -10990,8 +10988,13 @@ up.form = (function () {
10990
10988
  const element = up.fragment.get(elementOrSelector, options);
10991
10989
  return element.form || element.closest('form');
10992
10990
  }
10993
- function getScope(element, options) {
10994
- return getForm(element, options) || up.layer.get(element).element;
10991
+ function getScope(origin, options) {
10992
+ if (origin) {
10993
+ return getForm(origin, options) || up.layer.get(origin).element;
10994
+ }
10995
+ else {
10996
+ return up.layer.current.element;
10997
+ }
10995
10998
  }
10996
10999
  function focusedField() {
10997
11000
  return u.presence(document.activeElement, isField);
@@ -11106,7 +11109,7 @@ up.status = (function () {
11106
11109
  let focusCapsule = up.FocusCapsule.preserve(bindLayer);
11107
11110
  let applyPreviews = () => doRunPreviews(request, renderOptions);
11108
11111
  let revertPreviews = bindLayer.asCurrent(applyPreviews);
11109
- up.on('focusin', { once: true }, () => focusCapsule = null);
11112
+ focusCapsule === null || focusCapsule === void 0 ? void 0 : focusCapsule.autoVoid();
11110
11113
  return () => {
11111
11114
  bindLayer.asCurrent(revertPreviews);
11112
11115
  focusCapsule === null || focusCapsule === void 0 ? void 0 : focusCapsule.restore(bindLayer, { preventScroll: true });