unpoly-rails 2.5.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of unpoly-rails might be problematic. Click here for more details.

@@ -8,7 +8,7 @@
8
8
  @module up
9
9
  */
10
10
  window.up = {
11
- version: '2.5.1'
11
+ version: '2.6.0'
12
12
  };
13
13
 
14
14
 
@@ -2167,7 +2167,36 @@ up.error = (function () {
2167
2167
  var message = error.message;
2168
2168
  up.emit(window, 'error', { message: message, error: error, log: false });
2169
2169
  }
2170
+ /*-
2171
+ Throws a [JavaScript error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
2172
+ with the given message.
2173
+
2174
+ The message may contain [substitution marks](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).
2175
+
2176
+ ### Examples
2177
+
2178
+ up.fail('Division by zero')
2179
+ up.fail('Unexpected result %o', result)
2180
+
2181
+ @function up.fail
2182
+ @param {string} message
2183
+ A message with details about the error.
2184
+
2185
+ The message can contain [substitution marks](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions)
2186
+ like `%s` or `%o`.
2187
+ @param {Array<string>} vars...
2188
+ A list of variables to replace any substitution marks in the error message.
2189
+ @internal
2190
+ */
2191
+ function fail() {
2192
+ var args = [];
2193
+ for (var _i = 0; _i < arguments.length; _i++) {
2194
+ args[_i] = arguments[_i];
2195
+ }
2196
+ throw up.error.failed(args);
2197
+ }
2170
2198
  return {
2199
+ fail: fail,
2171
2200
  failed: failed,
2172
2201
  aborted: aborted,
2173
2202
  invalidSelector: invalidSelector,
@@ -2176,6 +2205,7 @@ up.error = (function () {
2176
2205
  emitGlobal: emitGlobal
2177
2206
  };
2178
2207
  })();
2208
+ up.fail = up.error.fail;
2179
2209
 
2180
2210
 
2181
2211
  /***/ }),
@@ -2837,11 +2867,11 @@ up.element = (function () {
2837
2867
  The [text content](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) of the created element.
2838
2868
  @param {Object} [attrs.content]
2839
2869
  The [inner HTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) of the created element.
2840
- @param {Object} [attrs.style]
2870
+ @param {Object|string} [attrs.style]
2841
2871
  An object of CSS properties that will be set as the inline style
2842
- of the created element.
2872
+ of the created element. The given object may use kebab-case or camelCase keys.
2843
2873
 
2844
- The given object may use kebab-case or camelCase keys.
2874
+ You may also pass a string with semicolon-separated styles.
2845
2875
  @return {Element}
2846
2876
  The created element.
2847
2877
  @stable
@@ -2949,7 +2979,7 @@ up.element = (function () {
2949
2979
  An object of attributes to set on the created element.
2950
2980
  @param {Object} attrs.text
2951
2981
  The [text content](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) of the created element.
2952
- @param {Object} attrs.style
2982
+ @param {Object|string} attrs.style
2953
2983
  An object of CSS properties that will be set as the inline style
2954
2984
  of the created element.
2955
2985
 
@@ -3466,11 +3496,16 @@ up.element = (function () {
3466
3496
  @stable
3467
3497
  */
3468
3498
  function setInlineStyle(element, props) {
3469
- var style = element.style;
3470
- for (var key in props) {
3471
- var value = props[key];
3472
- value = normalizeStyleValueForWrite(key, value);
3473
- style[key] = value;
3499
+ if (u.isString(props)) {
3500
+ element.setAttribute('style', props);
3501
+ }
3502
+ else {
3503
+ var style = element.style;
3504
+ for (var key in props) {
3505
+ var value = props[key];
3506
+ value = normalizeStyleValueForWrite(key, value);
3507
+ style[key] = value;
3508
+ }
3474
3509
  }
3475
3510
  }
3476
3511
  function normalizeStyleValueForWrite(key, value) {
@@ -4633,8 +4668,16 @@ up.Change.UpdateLayer = /** @class */ (function (_super) {
4633
4668
  up.fragment.markAsDestroying(step.oldElement);
4634
4669
  }, afterInsert: function () {
4635
4670
  _this.responseDoc.finalizeElement(step.newElement);
4671
+ step.keepPlans.forEach(_this.reviveKeepable);
4672
+ // In the case of [up-keep] descendants, keepable elements are now transferred
4673
+ // to step.newElement, leaving a clone in their old DOM Position.
4674
+ // up.hello() is aware of step.keepPlans and will not compile kept elements a second time.
4636
4675
  up.hello(step.newElement, step);
4637
4676
  }, beforeDetach: function () {
4677
+ // In the case of [up-keep] descendants, keepable elements have been replaced
4678
+ // with a clone in step.oldElement. However, since that clone was never compiled,
4679
+ // it does not have destructors registered. Hence we will not clean the clone
4680
+ // unnecessarily.
4638
4681
  up.syntax.clean(step.oldElement, { layer: _this.layer });
4639
4682
  }, afterDetach: function () {
4640
4683
  e.remove(step.oldElement); // clean up jQuery data
@@ -4762,9 +4805,10 @@ up.Change.UpdateLayer = /** @class */ (function (_super) {
4762
4805
  if (step.keep) {
4763
4806
  for (var _i = 0, _a = step.oldElement.querySelectorAll('[up-keep]'); _i < _a.length; _i++) {
4764
4807
  var keepable = _a[_i];
4765
- var plan = this.findKeepPlan(__assign(__assign({}, step), { oldElement: keepable, descendantsOnly: true }));
4766
- if (plan) {
4808
+ var keepPlan = this.findKeepPlan(__assign(__assign({}, step), { oldElement: keepable, descendantsOnly: true }));
4809
+ if (keepPlan) {
4767
4810
  // plan.oldElement is now keepable
4811
+ this.hibernateKeepable(keepPlan);
4768
4812
  // Replace keepable with its clone so it looks good in a transition between
4769
4813
  // oldElement and newElement. Note that keepable will still point to the same element
4770
4814
  // after the replacement, which is now detached.
@@ -4772,8 +4816,8 @@ up.Change.UpdateLayer = /** @class */ (function (_super) {
4772
4816
  e.replace(keepable, keepableClone);
4773
4817
  // Since we're going to swap the entire oldElement and newElement containers afterwards,
4774
4818
  // replace the matching element with keepable so it will eventually return to the DOM.
4775
- e.replace(plan.newElement, keepable);
4776
- keepPlans.push(plan);
4819
+ e.replace(keepPlan.newElement, keepable);
4820
+ keepPlans.push(keepPlan);
4777
4821
  }
4778
4822
  }
4779
4823
  }
@@ -4795,6 +4839,19 @@ up.Change.UpdateLayer = /** @class */ (function (_super) {
4795
4839
  }
4796
4840
  }
4797
4841
  };
4842
+ UpdateLayer.prototype.hibernateKeepable = function (keepPlan) {
4843
+ var viewports = up.viewport.subtree(keepPlan.oldElement);
4844
+ keepPlan.revivers = viewports.map(function (viewport) {
4845
+ var scrollTop = viewport.scrollTop, scrollLeft = viewport.scrollLeft;
4846
+ return function () { return u.assign(viewport, { scrollTop: scrollTop, scrollLeft: scrollLeft }); };
4847
+ });
4848
+ };
4849
+ UpdateLayer.prototype.reviveKeepable = function (keepPlan) {
4850
+ for (var _i = 0, _a = keepPlan.revivers; _i < _a.length; _i++) {
4851
+ var reviver = _a[_i];
4852
+ reviver();
4853
+ }
4854
+ };
4798
4855
  UpdateLayer.prototype.matchPreflight = function () {
4799
4856
  if (this.matchedPreflight) {
4800
4857
  return;
@@ -4966,7 +5023,7 @@ up.Change.CloseLayer = /** @class */ (function (_super) {
4966
5023
  // The close event is emitted on the layer that is about to close.
4967
5024
  return this.layer.emit(this.buildEvent("up:layer:".concat(this.verb)), {
4968
5025
  callback: this.layer.callback("on".concat(u.upperCaseFirst(this.verb))),
4969
- log: "Will ".concat(this.verb, " ").concat(this.layer)
5026
+ log: ["Will ".concat(this.verb, " ").concat(this.layer, " with value %o"), this.value]
4970
5027
  });
4971
5028
  };
4972
5029
  CloseLayer.prototype.emitClosedEvent = function (formerParent) {
@@ -4984,7 +5041,7 @@ up.Change.CloseLayer = /** @class */ (function (_super) {
4984
5041
  baseLayer: formerParent,
4985
5042
  callback: this.layer.callback("on".concat(verbPastUpperCaseFirst)),
4986
5043
  ensureBubbles: true,
4987
- log: "".concat(verbPastUpperCaseFirst, " ").concat(this.layer)
5044
+ log: ["".concat(verbPastUpperCaseFirst, " ").concat(this.layer, " with value %o"), this.value]
4988
5045
  });
4989
5046
  };
4990
5047
  CloseLayer.prototype.buildEvent = function (name) {
@@ -6588,6 +6645,117 @@ up.FragmentFocus = /** @class */ (function (_super) {
6588
6645
  /* 33 */
6589
6646
  /***/ (function() {
6590
6647
 
6648
+ var e = up.element;
6649
+ var u = up.util;
6650
+ up.FragmentPolling = /** @class */ (function () {
6651
+ function FragmentPolling(fragment) {
6652
+ this.options = {};
6653
+ this.state = 'initialized';
6654
+ this.setFragment(fragment);
6655
+ }
6656
+ FragmentPolling.forFragment = function (fragment) {
6657
+ return fragment.upPolling || (fragment.upPolling = new this(fragment));
6658
+ };
6659
+ FragmentPolling.prototype.onPollAttributeObserved = function () {
6660
+ this.start();
6661
+ };
6662
+ FragmentPolling.prototype.onFragmentDestroyed = function () {
6663
+ // The element may come back (when it is swapped) or or may not come back (when it is destroyed).
6664
+ // If it does come back, `onPollAttributeObserved()` will restart the polling.
6665
+ this.stop();
6666
+ };
6667
+ FragmentPolling.prototype.start = function () {
6668
+ if (this.state !== 'started') {
6669
+ this.state = 'started';
6670
+ this.scheduleReload();
6671
+ }
6672
+ };
6673
+ FragmentPolling.prototype.stop = function () {
6674
+ if (this.state === 'started') {
6675
+ clearTimeout(this.reloadTimer);
6676
+ this.state = 'stopped';
6677
+ }
6678
+ };
6679
+ FragmentPolling.prototype.forceStart = function (options) {
6680
+ u.assign(this.options, options);
6681
+ this.forceStarted = true;
6682
+ this.start();
6683
+ };
6684
+ FragmentPolling.prototype.forceStop = function () {
6685
+ this.stop();
6686
+ this.forceStarted = false;
6687
+ };
6688
+ FragmentPolling.prototype.scheduleReload = function (delay) {
6689
+ var _this = this;
6690
+ if (delay === void 0) { delay = this.getInterval(); }
6691
+ this.reloadTimer = setTimeout(function () { return _this.reload(); }, delay);
6692
+ };
6693
+ FragmentPolling.prototype.reload = function () {
6694
+ var _this = this;
6695
+ // The setTimeout(doReload) callback might already be scheduled
6696
+ // before the polling stopped.
6697
+ if (this.state !== 'started') {
6698
+ return;
6699
+ }
6700
+ if (up.radio.shouldPoll(this.fragment)) {
6701
+ var reloadOptions = {
6702
+ url: this.options.url,
6703
+ guardEvent: up.event.build('up:fragment:poll', { log: 'Polling fragment' })
6704
+ };
6705
+ u.always(up.reload(this.fragment, reloadOptions), function (result) { return _this.onReloaded(result); });
6706
+ }
6707
+ else {
6708
+ up.puts('[up-poll]', 'Polling is disabled');
6709
+ // Reconsider after 10 seconds at most
6710
+ var reconsiderDisabledDelay = Math.min(10 * 1000, this.getInterval());
6711
+ this.scheduleReload(reconsiderDisabledDelay);
6712
+ }
6713
+ };
6714
+ FragmentPolling.prototype.onReloaded = function (result) {
6715
+ var _a;
6716
+ // Transfer this instance to the new fragment.
6717
+ // We can remove this in case we don't implement forced start/stop.
6718
+ var newFragment = (_a = result === null || result === void 0 ? void 0 : result.fragments) === null || _a === void 0 ? void 0 : _a[0];
6719
+ if (newFragment) {
6720
+ // No need to scheduleReload() in this branch:
6721
+ // (1) Either the new fragment also has an [up-poll] and we have already
6722
+ // started in #onPollAttributeObserved().
6723
+ // (2) Or we are force-started and we will start in #onFragmentSwapped().
6724
+ this.onFragmentSwapped(newFragment);
6725
+ }
6726
+ else {
6727
+ this.scheduleReload();
6728
+ }
6729
+ };
6730
+ FragmentPolling.prototype.onFragmentSwapped = function (newFragment) {
6731
+ // Transfer this polling to the new instance
6732
+ newFragment.upPolling = this;
6733
+ delete this.fragment.upPolling;
6734
+ this.setFragment(newFragment);
6735
+ if (this.state === 'stopped' && this.forceStarted) {
6736
+ // When polling was started programmatically through up.fragment.startPolling()
6737
+ // we don't require the updated fragment to have an [up-poll] attribute to
6738
+ // continue polling.
6739
+ this.start();
6740
+ }
6741
+ };
6742
+ FragmentPolling.prototype.setFragment = function (newFragment) {
6743
+ var _this = this;
6744
+ this.fragment = newFragment;
6745
+ up.destructor(newFragment, function () { return _this.onFragmentDestroyed(); });
6746
+ };
6747
+ FragmentPolling.prototype.getInterval = function () {
6748
+ var _a, _b;
6749
+ return (_b = (_a = this.options.interval) !== null && _a !== void 0 ? _a : e.numberAttr(this.fragment, 'up-interval')) !== null && _b !== void 0 ? _b : up.radio.config.pollInterval;
6750
+ };
6751
+ return FragmentPolling;
6752
+ }());
6753
+
6754
+
6755
+ /***/ }),
6756
+ /* 34 */
6757
+ /***/ (function() {
6758
+
6591
6759
  var __extends = (this && this.__extends) || (function () {
6592
6760
  var extendStatics = function (d, b) {
6593
6761
  extendStatics = Object.setPrototypeOf ||
@@ -6694,7 +6862,7 @@ up.FragmentScrolling = /** @class */ (function (_super) {
6694
6862
 
6695
6863
 
6696
6864
  /***/ }),
6697
- /* 34 */
6865
+ /* 35 */
6698
6866
  /***/ (function() {
6699
6867
 
6700
6868
  var u = up.util;
@@ -6737,7 +6905,7 @@ up.HTMLWrapper = /** @class */ (function () {
6737
6905
 
6738
6906
 
6739
6907
  /***/ }),
6740
- /* 35 */
6908
+ /* 36 */
6741
6909
  /***/ (function() {
6742
6910
 
6743
6911
  var __extends = (this && this.__extends) || (function () {
@@ -7499,7 +7667,7 @@ up.Layer = /** @class */ (function (_super) {
7499
7667
 
7500
7668
 
7501
7669
  /***/ }),
7502
- /* 36 */
7670
+ /* 37 */
7503
7671
  /***/ (function() {
7504
7672
 
7505
7673
  var __extends = (this && this.__extends) || (function () {
@@ -7687,12 +7855,6 @@ up.Layer.Overlay = /** @class */ (function (_super) {
7687
7855
  this.createDismissElement(this.getBoxElement());
7688
7856
  }
7689
7857
  if (this.supportsDismissMethod('outside')) {
7690
- this.unbindParentClicked = this.parent.on('up:click', function (event, element) {
7691
- // When our origin is clicked again, halt the click event
7692
- // We achieve this by halting the click event.
7693
- var originClicked = _this.origin && _this.origin.contains(element);
7694
- _this.onOutsideClicked(event, originClicked);
7695
- });
7696
7858
  // If this overlay has its own viewport, a click outside the frame will hit
7697
7859
  // the viewport and not the parent element.
7698
7860
  if (this.viewportElement) {
@@ -7703,6 +7865,18 @@ up.Layer.Overlay = /** @class */ (function (_super) {
7703
7865
  }
7704
7866
  });
7705
7867
  }
7868
+ else {
7869
+ // Only bind to the parent if there's not already a viewport.
7870
+ // This prevents issues with other overlay libs appending elements to document.body,
7871
+ // but overlaying this overlay with a huge z-index. Clicking such a foreign overlay
7872
+ // would close this layer, as Unpoly considers it to be on the root layer (our parent).2
7873
+ this.unbindParentClicked = this.parent.on('up:click', function (event, element) {
7874
+ // When our origin is clicked again, halt the click event
7875
+ // We achieve this by halting the click event.
7876
+ var originClicked = _this.origin && _this.origin.contains(element);
7877
+ _this.onOutsideClicked(event, originClicked);
7878
+ });
7879
+ }
7706
7880
  }
7707
7881
  if (this.supportsDismissMethod('key')) {
7708
7882
  this.unbindEscapePressed = up.event.onEscape(function (event) { return _this.onEscapePressed(event); });
@@ -7725,7 +7899,7 @@ up.Layer.Overlay = /** @class */ (function (_super) {
7725
7899
  if (halt) {
7726
7900
  up.event.halt(event);
7727
7901
  }
7728
- this.dismiss(':outside');
7902
+ this.dismiss(':outside', { origin: event.target });
7729
7903
  };
7730
7904
  Overlay.prototype.onEscapePressed = function (event) {
7731
7905
  // All overlays listen to the Escape key being pressed, but only the front layer
@@ -7752,7 +7926,7 @@ up.Layer.Overlay = /** @class */ (function (_super) {
7752
7926
  // Since we're defining this handler on up.Overlay, we will not prevent
7753
7927
  // a link from being followed on the root layer.
7754
7928
  up.event.halt(event);
7755
- var origin = event.target.closest(selector);
7929
+ var origin = e.closest(event.target, selector);
7756
7930
  var value = e.jsonAttr(origin, attribute);
7757
7931
  var closeOptions = { origin: origin };
7758
7932
  var parser = new up.OptionsParser(closeOptions, origin);
@@ -7890,7 +8064,7 @@ up.Layer.Overlay = /** @class */ (function (_super) {
7890
8064
 
7891
8065
 
7892
8066
  /***/ }),
7893
- /* 37 */
8067
+ /* 38 */
7894
8068
  /***/ (function() {
7895
8069
 
7896
8070
  var __extends = (this && this.__extends) || (function () {
@@ -7955,7 +8129,7 @@ up.Layer.OverlayWithTether = /** @class */ (function (_super) {
7955
8129
 
7956
8130
 
7957
8131
  /***/ }),
7958
- /* 38 */
8132
+ /* 39 */
7959
8133
  /***/ (function() {
7960
8134
 
7961
8135
  var __extends = (this && this.__extends) || (function () {
@@ -8027,7 +8201,7 @@ up.Layer.OverlayWithViewport = (_a = /** @class */ (function (_super) {
8027
8201
 
8028
8202
 
8029
8203
  /***/ }),
8030
- /* 39 */
8204
+ /* 40 */
8031
8205
  /***/ (function() {
8032
8206
 
8033
8207
  var __extends = (this && this.__extends) || (function () {
@@ -8121,7 +8295,7 @@ up.Layer.Root = (_a = /** @class */ (function (_super) {
8121
8295
 
8122
8296
 
8123
8297
  /***/ }),
8124
- /* 40 */
8298
+ /* 41 */
8125
8299
  /***/ (function() {
8126
8300
 
8127
8301
  var __extends = (this && this.__extends) || (function () {
@@ -8152,7 +8326,7 @@ up.Layer.Modal = (_a = /** @class */ (function (_super) {
8152
8326
 
8153
8327
 
8154
8328
  /***/ }),
8155
- /* 41 */
8329
+ /* 42 */
8156
8330
  /***/ (function() {
8157
8331
 
8158
8332
  var __extends = (this && this.__extends) || (function () {
@@ -8183,7 +8357,7 @@ up.Layer.Popup = (_a = /** @class */ (function (_super) {
8183
8357
 
8184
8358
 
8185
8359
  /***/ }),
8186
- /* 42 */
8360
+ /* 43 */
8187
8361
  /***/ (function() {
8188
8362
 
8189
8363
  var __extends = (this && this.__extends) || (function () {
@@ -8214,7 +8388,7 @@ up.Layer.Drawer = (_a = /** @class */ (function (_super) {
8214
8388
 
8215
8389
 
8216
8390
  /***/ }),
8217
- /* 43 */
8391
+ /* 44 */
8218
8392
  /***/ (function() {
8219
8393
 
8220
8394
  var __extends = (this && this.__extends) || (function () {
@@ -8245,7 +8419,7 @@ up.Layer.Cover = (_a = /** @class */ (function (_super) {
8245
8419
 
8246
8420
 
8247
8421
  /***/ }),
8248
- /* 44 */
8422
+ /* 45 */
8249
8423
  /***/ (function() {
8250
8424
 
8251
8425
  var __assign = (this && this.__assign) || function () {
@@ -8370,7 +8544,7 @@ up.LayerLookup = /** @class */ (function () {
8370
8544
 
8371
8545
 
8372
8546
  /***/ }),
8373
- /* 45 */
8547
+ /* 46 */
8374
8548
  /***/ (function() {
8375
8549
 
8376
8550
  var __extends = (this && this.__extends) || (function () {
@@ -8575,7 +8749,7 @@ up.LayerStack = /** @class */ (function (_super) {
8575
8749
 
8576
8750
 
8577
8751
  /***/ }),
8578
- /* 46 */
8752
+ /* 47 */
8579
8753
  /***/ (function() {
8580
8754
 
8581
8755
  up.LinkFeedbackURLs = /** @class */ (function () {
@@ -8610,7 +8784,7 @@ up.LinkFeedbackURLs = /** @class */ (function () {
8610
8784
 
8611
8785
 
8612
8786
  /***/ }),
8613
- /* 47 */
8787
+ /* 48 */
8614
8788
  /***/ (function() {
8615
8789
 
8616
8790
  var u = up.util;
@@ -8691,7 +8865,7 @@ up.LinkPreloader = /** @class */ (function () {
8691
8865
 
8692
8866
 
8693
8867
  /***/ }),
8694
- /* 48 */
8868
+ /* 49 */
8695
8869
  /***/ (function() {
8696
8870
 
8697
8871
  var __assign = (this && this.__assign) || function () {
@@ -8944,7 +9118,7 @@ up.MotionController = /** @class */ (function () {
8944
9118
 
8945
9119
 
8946
9120
  /***/ }),
8947
- /* 49 */
9121
+ /* 50 */
8948
9122
  /***/ (function() {
8949
9123
 
8950
9124
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
@@ -9075,7 +9249,7 @@ up.NonceableCallback = /** @class */ (function () {
9075
9249
 
9076
9250
 
9077
9251
  /***/ }),
9078
- /* 50 */
9252
+ /* 51 */
9079
9253
  /***/ (function() {
9080
9254
 
9081
9255
  var __assign = (this && this.__assign) || function () {
@@ -9153,7 +9327,7 @@ up.OptionsParser = /** @class */ (function () {
9153
9327
 
9154
9328
 
9155
9329
  /***/ }),
9156
- /* 51 */
9330
+ /* 52 */
9157
9331
  /***/ (function() {
9158
9332
 
9159
9333
  var e = up.element;
@@ -9247,7 +9421,7 @@ up.OverlayFocus = /** @class */ (function () {
9247
9421
 
9248
9422
 
9249
9423
  /***/ }),
9250
- /* 52 */
9424
+ /* 53 */
9251
9425
  /***/ (function() {
9252
9426
 
9253
9427
  var u = up.util;
@@ -9844,7 +10018,7 @@ up.Params = /** @class */ (function () {
9844
10018
 
9845
10019
 
9846
10020
  /***/ }),
9847
- /* 53 */
10021
+ /* 54 */
9848
10022
  /***/ (function() {
9849
10023
 
9850
10024
  var e = up.element;
@@ -9902,7 +10076,7 @@ up.ProgressBar = /** @class */ (function () {
9902
10076
 
9903
10077
 
9904
10078
  /***/ }),
9905
- /* 54 */
10079
+ /* 55 */
9906
10080
  /***/ (function() {
9907
10081
 
9908
10082
  var u = up.util;
@@ -10041,7 +10215,7 @@ up.RenderOptions = (function () {
10041
10215
 
10042
10216
 
10043
10217
  /***/ }),
10044
- /* 55 */
10218
+ /* 56 */
10045
10219
  /***/ (function() {
10046
10220
 
10047
10221
  var __extends = (this && this.__extends) || (function () {
@@ -10102,7 +10276,7 @@ up.RenderResult = /** @class */ (function (_super) {
10102
10276
 
10103
10277
 
10104
10278
  /***/ }),
10105
- /* 56 */
10279
+ /* 57 */
10106
10280
  /***/ (function() {
10107
10281
 
10108
10282
  var __extends = (this && this.__extends) || (function () {
@@ -10168,8 +10342,18 @@ up.Request = /** @class */ (function (_super) {
10168
10342
  // Normalize a first time to get a normalized cache key.
10169
10343
  _this.normalizeForCaching();
10170
10344
  if (!options.basic) {
10171
- _this.layer = up.layer.get(_this.layer); // If @layer and @origin is undefined, this will choose the current layer.
10172
- _this.failLayer = up.layer.get(_this.failLayer || _this.layer);
10345
+ var layerLookupOptions = { origin: _this.origin };
10346
+ // Calling up.layer.get() will give us:
10347
+ //
10348
+ // (1) Resolution of strings like 'current' to an up.Layer instance
10349
+ // (2) Default of origin's layer
10350
+ // (3) Default of up.layer.current
10351
+ //
10352
+ // up.layer.get('new') will return 'new' unchanged, but I'm not sure
10353
+ // if any code actually calls up.request({ ..., layer: 'new' }).
10354
+ // In up.Change.OpenLayer we connect requests to the base layer we're stacking upon.
10355
+ _this.layer = up.layer.get(_this.layer, layerLookupOptions);
10356
+ _this.failLayer = up.layer.get(_this.failLayer || _this.layer, layerLookupOptions);
10173
10357
  _this.context || (_this.context = _this.layer.context || {}); // @layer might be "new", so we default to {}
10174
10358
  _this.failContext || (_this.failContext = _this.failLayer.context || {}); // @failLayer might be "new", so we default to {}
10175
10359
  _this.mode || (_this.mode = _this.layer.mode);
@@ -10724,7 +10908,7 @@ up.Request.tester = function (condition) {
10724
10908
 
10725
10909
 
10726
10910
  /***/ }),
10727
- /* 57 */
10911
+ /* 58 */
10728
10912
  /***/ (function() {
10729
10913
 
10730
10914
  var __extends = (this && this.__extends) || (function () {
@@ -10791,7 +10975,7 @@ up.Request.Cache = /** @class */ (function (_super) {
10791
10975
 
10792
10976
 
10793
10977
  /***/ }),
10794
- /* 58 */
10978
+ /* 59 */
10795
10979
  /***/ (function() {
10796
10980
 
10797
10981
  var u = up.util;
@@ -10945,7 +11129,7 @@ up.Request.Queue = /** @class */ (function () {
10945
11129
 
10946
11130
 
10947
11131
  /***/ }),
10948
- /* 59 */
11132
+ /* 60 */
10949
11133
  /***/ (function() {
10950
11134
 
10951
11135
  var u = up.util;
@@ -10998,7 +11182,7 @@ up.Request.FormRenderer = /** @class */ (function () {
10998
11182
 
10999
11183
 
11000
11184
  /***/ }),
11001
- /* 60 */
11185
+ /* 61 */
11002
11186
  /***/ (function() {
11003
11187
 
11004
11188
  var CONTENT_TYPE_URL_ENCODED = 'application/x-www-form-urlencoded';
@@ -11106,7 +11290,7 @@ up.Request.XHRRenderer = /** @class */ (function () {
11106
11290
 
11107
11291
 
11108
11292
  /***/ }),
11109
- /* 61 */
11293
+ /* 62 */
11110
11294
  /***/ (function() {
11111
11295
 
11112
11296
  var __extends = (this && this.__extends) || (function () {
@@ -11324,7 +11508,7 @@ up.Response = /** @class */ (function (_super) {
11324
11508
 
11325
11509
 
11326
11510
  /***/ }),
11327
- /* 62 */
11511
+ /* 63 */
11328
11512
  /***/ (function() {
11329
11513
 
11330
11514
  var u = up.util;
@@ -11433,7 +11617,7 @@ up.ResponseDoc = /** @class */ (function () {
11433
11617
 
11434
11618
 
11435
11619
  /***/ }),
11436
- /* 63 */
11620
+ /* 64 */
11437
11621
  /***/ (function() {
11438
11622
 
11439
11623
  var e = up.element;
@@ -11555,7 +11739,7 @@ up.RevealMotion = /** @class */ (function () {
11555
11739
 
11556
11740
 
11557
11741
  /***/ }),
11558
- /* 64 */
11742
+ /* 65 */
11559
11743
  /***/ (function() {
11560
11744
 
11561
11745
  var u = up.util;
@@ -11604,11 +11788,6 @@ up.ScrollMotion = /** @class */ (function () {
11604
11788
  if (this.settled) {
11605
11789
  return;
11606
11790
  }
11607
- // When the scroll position is not the one we previously set, we assume
11608
- // that the user has tried scrolling on her own. We then cancel the scrolling animation.
11609
- if (this.frameTop && (Math.abs(this.frameTop - this.scrollable.scrollTop) > 1.5)) {
11610
- this.abort('Animation aborted due to user intervention');
11611
- }
11612
11791
  var currentTime = Date.now();
11613
11792
  var timeElapsed = currentTime - this.startTime;
11614
11793
  var timeFraction = Math.min(timeElapsed / this.duration, 1);
@@ -11640,7 +11819,7 @@ up.ScrollMotion = /** @class */ (function () {
11640
11819
 
11641
11820
 
11642
11821
  /***/ }),
11643
- /* 65 */
11822
+ /* 66 */
11644
11823
  /***/ (function() {
11645
11824
 
11646
11825
  var e = up.element;
@@ -11694,7 +11873,7 @@ up.Selector = /** @class */ (function () {
11694
11873
 
11695
11874
 
11696
11875
  /***/ }),
11697
- /* 66 */
11876
+ /* 67 */
11698
11877
  /***/ (function() {
11699
11878
 
11700
11879
  var u = up.util;
@@ -11729,7 +11908,7 @@ up.store.Memory = /** @class */ (function () {
11729
11908
 
11730
11909
 
11731
11910
  /***/ }),
11732
- /* 67 */
11911
+ /* 68 */
11733
11912
  /***/ (function() {
11734
11913
 
11735
11914
  var __extends = (this && this.__extends) || (function () {
@@ -11817,7 +11996,7 @@ up.store.Session = /** @class */ (function (_super) {
11817
11996
 
11818
11997
 
11819
11998
  /***/ }),
11820
- /* 68 */
11999
+ /* 69 */
11821
12000
  /***/ (function() {
11822
12001
 
11823
12002
  var u = up.util;
@@ -11979,7 +12158,7 @@ up.Tether = /** @class */ (function () {
11979
12158
 
11980
12159
 
11981
12160
  /***/ }),
11982
- /* 69 */
12161
+ /* 70 */
11983
12162
  /***/ (function() {
11984
12163
 
11985
12164
  var u = up.util;
@@ -12073,7 +12252,7 @@ up.URLPattern = /** @class */ (function () {
12073
12252
 
12074
12253
 
12075
12254
  /***/ }),
12076
- /* 70 */
12255
+ /* 71 */
12077
12256
  /***/ (function() {
12078
12257
 
12079
12258
  /*-
@@ -12284,7 +12463,7 @@ up.boot = up.framework.boot;
12284
12463
 
12285
12464
 
12286
12465
  /***/ }),
12287
- /* 71 */
12466
+ /* 72 */
12288
12467
  /***/ (function() {
12289
12468
 
12290
12469
  /*-
@@ -12877,7 +13056,7 @@ up.emit = up.event.emit;
12877
13056
 
12878
13057
 
12879
13058
  /***/ }),
12880
- /* 72 */
13059
+ /* 73 */
12881
13060
  /***/ (function() {
12882
13061
 
12883
13062
  /*-
@@ -13676,7 +13855,7 @@ up.protocol = (function () {
13676
13855
 
13677
13856
 
13678
13857
  /***/ }),
13679
- /* 73 */
13858
+ /* 74 */
13680
13859
  /***/ (function() {
13681
13860
 
13682
13861
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
@@ -13855,37 +14034,6 @@ up.log = (function () {
13855
14034
  setEnabled(false);
13856
14035
  }
13857
14036
  /*-
13858
- Throws a [JavaScript error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
13859
- with the given message.
13860
-
13861
- The message will also be printed to the error log. Also a notification will be shown at the bottom of the screen.
13862
-
13863
- The message may contain [substitution marks](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).
13864
-
13865
- ### Examples
13866
-
13867
- up.fail('Division by zero')
13868
- up.fail('Unexpected result %o', result)
13869
-
13870
- @function up.fail
13871
- @param {string} message
13872
- A message with details about the error.
13873
-
13874
- The message can contain [substitution marks](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions)
13875
- like `%s` or `%o`.
13876
- @param {Array<string>} vars...
13877
- A list of variables to replace any substitution marks in the error message.
13878
- @experimental
13879
- */
13880
- function fail() {
13881
- var args = [];
13882
- for (var _i = 0; _i < arguments.length; _i++) {
13883
- args[_i] = arguments[_i];
13884
- }
13885
- printToError.apply(void 0, __spreadArray(['error'], args, false));
13886
- throw up.error.failed(args);
13887
- }
13888
- /*-
13889
14037
  Registers an empty rejection handler in case the given promise
13890
14038
  rejects with an AbortError or a failed up.Response.
13891
14039
 
@@ -13921,18 +14069,16 @@ up.log = (function () {
13921
14069
  config: config,
13922
14070
  enable: enable,
13923
14071
  disable: disable,
13924
- fail: fail,
13925
14072
  muteUncriticalRejection: muteUncriticalRejection,
13926
14073
  isEnabled: function () { return config.enabled; },
13927
14074
  };
13928
14075
  })();
13929
14076
  up.puts = up.log.puts;
13930
14077
  up.warn = up.log.warn;
13931
- up.fail = up.log.fail;
13932
14078
 
13933
14079
 
13934
14080
  /***/ }),
13935
- /* 74 */
14081
+ /* 75 */
13936
14082
  /***/ (function() {
13937
14083
 
13938
14084
  /*-
@@ -14258,7 +14404,6 @@ up.syntax = (function () {
14258
14404
  isDefault: up.framework.evaling,
14259
14405
  priority: 0,
14260
14406
  batch: false,
14261
- keep: false,
14262
14407
  jQuery: false
14263
14408
  });
14264
14409
  return u.assign(callback, options);
@@ -14454,7 +14599,7 @@ up.data = up.syntax.data;
14454
14599
 
14455
14600
 
14456
14601
  /***/ }),
14457
- /* 75 */
14602
+ /* 76 */
14458
14603
  /***/ (function() {
14459
14604
 
14460
14605
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -14771,9 +14916,6 @@ up.history = (function () {
14771
14916
  return historyLayer.emit.apply(historyLayer, args);
14772
14917
  }
14773
14918
  function register() {
14774
- // Supported by all browser except IE:
14775
- // https://developer.mozilla.org/en-US/docs/Web/API/History/scrollRestoration
14776
- window.history.scrollRestoration = 'manual';
14777
14919
  window.addEventListener('popstate', onPop);
14778
14920
  // Unpoly replaces the initial page state so it can later restore it when the user
14779
14921
  // goes back to that initial URL. However, if the initial request was a POST,
@@ -14848,7 +14990,7 @@ up.history = (function () {
14848
14990
 
14849
14991
 
14850
14992
  /***/ }),
14851
- /* 76 */
14993
+ /* 77 */
14852
14994
  /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
14853
14995
 
14854
14996
  var __assign = (this && this.__assign) || function () {
@@ -14862,7 +15004,7 @@ var __assign = (this && this.__assign) || function () {
14862
15004
  };
14863
15005
  return __assign.apply(this, arguments);
14864
15006
  };
14865
- __webpack_require__(77);
15007
+ __webpack_require__(78);
14866
15008
  var u = up.util;
14867
15009
  var e = up.element;
14868
15010
  /*-
@@ -15720,7 +15862,7 @@ up.fragment = (function () {
15720
15862
  var keepPlans = options.keepPlans || [];
15721
15863
  var skip = keepPlans.map(function (plan) {
15722
15864
  emitFragmentKept(plan);
15723
- return plan.oldElement;
15865
+ return plan.oldElement; // the kept element
15724
15866
  });
15725
15867
  up.syntax.compile(element, { skip: skip, layer: options.layer });
15726
15868
  emitFragmentInserted(element, options);
@@ -16701,13 +16843,13 @@ u.delegate(up, 'context', function () { return up.layer.current; });
16701
16843
 
16702
16844
 
16703
16845
  /***/ }),
16704
- /* 77 */
16846
+ /* 78 */
16705
16847
  /***/ (function() {
16706
16848
 
16707
16849
 
16708
16850
 
16709
16851
  /***/ }),
16710
- /* 78 */
16852
+ /* 79 */
16711
16853
  /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
16712
16854
 
16713
16855
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
@@ -16719,7 +16861,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
16719
16861
  }
16720
16862
  return to.concat(ar || Array.prototype.slice.call(from));
16721
16863
  };
16722
- __webpack_require__(79);
16864
+ __webpack_require__(80);
16723
16865
  /*-
16724
16866
  Scrolling viewports
16725
16867
  ===================
@@ -16833,8 +16975,8 @@ up.viewport = (function () {
16833
16975
  The container element to scroll.
16834
16976
  @param {number} scrollPos
16835
16977
  The absolute number of pixels to set the scroll position to.
16836
- @param {string}[options.behavior='auto']
16837
- When set to `'auto'`, this will immediately scroll to the new position.
16978
+ @param {string}[options.behavior='instant']
16979
+ When set to `'instant'`, this will immediately scroll to the new position.
16838
16980
 
16839
16981
  When set to `'smooth'`, this will scroll smoothly to the new position.
16840
16982
  @param {number}[options.speed]
@@ -16907,8 +17049,8 @@ up.viewport = (function () {
16907
17049
 
16908
17050
  Defaults to `up.viewport.config.revealTop`.
16909
17051
 
16910
- @param {string}[options.behavior='auto']
16911
- When set to `'auto'`, this will immediately scroll to the new position.
17052
+ @param {string}[options.behavior='instant']
17053
+ When set to `'instant'`, this will immediately scroll to the new position.
16912
17054
 
16913
17055
  When set to `'smooth'`, this will scroll smoothly to the new position.
16914
17056
 
@@ -17014,7 +17156,7 @@ up.viewport = (function () {
17014
17156
  /*-
17015
17157
  [Reveals](/up.reveal) an element matching the given `#hash` anchor.
17016
17158
 
17017
- Other than the default behavior found in browsers, `up.revealHash` works with
17159
+ Other than the default behavior found in browsers, `up.revealHash()` works with
17018
17160
  [multiple viewports](/up-viewport) and honors [fixed elements](/up-fixed-top) obstructing the user's
17019
17161
  view of the viewport.
17020
17162
 
@@ -17598,13 +17740,13 @@ up.reveal = up.viewport.reveal;
17598
17740
 
17599
17741
 
17600
17742
  /***/ }),
17601
- /* 79 */
17743
+ /* 80 */
17602
17744
  /***/ (function() {
17603
17745
 
17604
17746
 
17605
17747
 
17606
17748
  /***/ }),
17607
- /* 80 */
17749
+ /* 81 */
17608
17750
  /***/ (function() {
17609
17751
 
17610
17752
  var __assign = (this && this.__assign) || function () {
@@ -18358,10 +18500,10 @@ up.animate = up.motion.animate;
18358
18500
 
18359
18501
 
18360
18502
  /***/ }),
18361
- /* 81 */
18503
+ /* 82 */
18362
18504
  /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
18363
18505
 
18364
- __webpack_require__(82);
18506
+ __webpack_require__(83);
18365
18507
  var u = up.util;
18366
18508
  /*-
18367
18509
  Network requests
@@ -19254,13 +19396,13 @@ up.cache = up.network.cache;
19254
19396
 
19255
19397
 
19256
19398
  /***/ }),
19257
- /* 82 */
19399
+ /* 83 */
19258
19400
  /***/ (function() {
19259
19401
 
19260
19402
 
19261
19403
 
19262
19404
  /***/ }),
19263
- /* 83 */
19405
+ /* 84 */
19264
19406
  /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
19265
19407
 
19266
19408
  var __assign = (this && this.__assign) || function () {
@@ -19319,7 +19461,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19319
19461
  }
19320
19462
  return to.concat(ar || Array.prototype.slice.call(from));
19321
19463
  };
19322
- __webpack_require__(84);
19464
+ __webpack_require__(85);
19323
19465
  var u = up.util;
19324
19466
  var e = up.element;
19325
19467
  /*-
@@ -19461,6 +19603,11 @@ up.layer = (function () {
19461
19603
  If set to `true`, the overlay will always render history.
19462
19604
  If set to `false`, the overlay will never render history.
19463
19605
 
19606
+ @param {string} [config.overlay.class]
19607
+ An HTML class for the overlay's container element.
19608
+
19609
+ See [overlay classes](/customizing-overlays#overlay-classes).
19610
+
19464
19611
  @param {object} config.modal
19465
19612
  Defaults for [modal overlays](/layer-terminology).
19466
19613
 
@@ -20328,6 +20475,8 @@ up.layer = (function () {
20328
20475
  @event up:layer:accept
20329
20476
  @param {up.Layer} event.layer
20330
20477
  The layer that is about to close.
20478
+ @param {Element} [event.value]
20479
+ The overlay's [acceptance value](/closing-overlays#overlay-result-values).
20331
20480
  @param {Element} [event.origin]
20332
20481
  The element that is causing the layer to close.
20333
20482
  @param event.preventDefault()
@@ -20344,6 +20493,8 @@ up.layer = (function () {
20344
20493
  @event up:layer:accepted
20345
20494
  @param {up.Layer} event.layer
20346
20495
  The layer that was closed.
20496
+ @param {Element} [event.value]
20497
+ The overlay's [acceptance value](/closing-overlays#overlay-result-values).
20347
20498
  @param {Element} [event.origin]
20348
20499
  The element that has caused the layer to close.
20349
20500
  @stable
@@ -20367,6 +20518,8 @@ up.layer = (function () {
20367
20518
  @event up:layer:dismiss
20368
20519
  @param {up.Layer} event.layer
20369
20520
  The layer that is about to close.
20521
+ @param {Element} [event.value]
20522
+ The overlay's [dismissal value](/closing-overlays#overlay-result-values).
20370
20523
  @param {Element} [event.origin]
20371
20524
  The element that is causing the layer to close.
20372
20525
  @param event.preventDefault()
@@ -20383,6 +20536,8 @@ up.layer = (function () {
20383
20536
  @event up:layer:dismissed
20384
20537
  @param {up.Layer} event.layer
20385
20538
  The layer that was closed.
20539
+ @param {Element} [event.value]
20540
+ The overlay's [dismissal value](/closing-overlays#overlay-result-values).
20386
20541
  @param {Element} [event.origin]
20387
20542
  The element that has caused the layer to close.
20388
20543
  @stable
@@ -20588,13 +20743,13 @@ up.layer = (function () {
20588
20743
 
20589
20744
 
20590
20745
  /***/ }),
20591
- /* 84 */
20746
+ /* 85 */
20592
20747
  /***/ (function() {
20593
20748
 
20594
20749
 
20595
20750
 
20596
20751
  /***/ }),
20597
- /* 85 */
20752
+ /* 86 */
20598
20753
  /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
20599
20754
 
20600
20755
  var __assign = (this && this.__assign) || function () {
@@ -20617,7 +20772,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20617
20772
  }
20618
20773
  return to.concat(ar || Array.prototype.slice.call(from));
20619
20774
  };
20620
- __webpack_require__(86);
20775
+ __webpack_require__(87);
20621
20776
  /*-
20622
20777
  Linking to fragments
20623
20778
  ====================
@@ -21596,12 +21751,6 @@ up.link = (function () {
21596
21751
  A JSON object that will be merged into the [context](/context)
21597
21752
  of the current layer once the fragment is rendered.
21598
21753
 
21599
- @param [up-keep='true']
21600
- Whether [`[up-keep]`](/up-keep) elements will be preserved in the updated fragment.
21601
-
21602
- @param [up-hungry='true']
21603
- Whether [`[up-hungry]`](/up-hungry) elements outside the updated fragment will also be updated.
21604
-
21605
21754
  @param [up-scroll='auto']
21606
21755
  How to scroll after the new fragment was rendered.
21607
21756
 
@@ -21776,13 +21925,13 @@ up.follow = up.link.follow;
21776
21925
 
21777
21926
 
21778
21927
  /***/ }),
21779
- /* 86 */
21928
+ /* 87 */
21780
21929
  /***/ (function() {
21781
21930
 
21782
21931
 
21783
21932
 
21784
21933
  /***/ }),
21785
- /* 87 */
21934
+ /* 88 */
21786
21935
  /***/ (function() {
21787
21936
 
21788
21937
  var __assign = (this && this.__assign) || function () {
@@ -21832,7 +21981,7 @@ up.form = (function () {
21832
21981
  up.form.config.submitSelectors.push('form')
21833
21982
  ```
21834
21983
 
21835
- Individual forms may opt out with an `[up-submit=follow]` attribute.
21984
+ Individual forms may opt out with an `[up-submit=false]` attribute.
21836
21985
  You may configure additional exceptions in `config.noSubmitSelectors`.
21837
21986
 
21838
21987
  @param {Array<string>} [config.noSubmitSelectors]
@@ -23095,7 +23244,7 @@ up.validate = up.form.validate;
23095
23244
 
23096
23245
 
23097
23246
  /***/ }),
23098
- /* 88 */
23247
+ /* 89 */
23099
23248
  /***/ (function() {
23100
23249
 
23101
23250
  /*-
@@ -23532,7 +23681,7 @@ up.feedback = (function () {
23532
23681
 
23533
23682
 
23534
23683
  /***/ }),
23535
- /* 89 */
23684
+ /* 90 */
23536
23685
  /***/ (function() {
23537
23686
 
23538
23687
  /*-
@@ -23548,7 +23697,6 @@ This package contains functionality to passively receive updates from the server
23548
23697
  */
23549
23698
  up.radio = (function () {
23550
23699
  var u = up.util;
23551
- var e = up.element;
23552
23700
  /*-
23553
23701
  Configures defaults for passive updates.
23554
23702
 
@@ -23566,7 +23714,7 @@ up.radio = (function () {
23566
23714
  @param {boolean|string|Function(Element)} [config.pollEnabled=true]
23567
23715
  Whether Unpoly will follow instructions to poll fragments, like the `[up-poll]` attribute.
23568
23716
 
23569
- When set to `'auto'` Unpoly will poll if one of the following applies:
23717
+ When set to `'auto'` Unpoly will skip polling updates while one of the following applies:
23570
23718
 
23571
23719
  - The browser tab is in the foreground
23572
23720
  - The fragment's layer is the [frontmost layer](/up.layer.front).
@@ -23578,6 +23726,9 @@ up.radio = (function () {
23578
23726
 
23579
23727
  You may also pass a function that accepts the polling fragment and returns `true`, `false` or `'auto'`.
23580
23728
 
23729
+ When an update is skipped due to polling being disabled,
23730
+ Unpoly will try to poll again after the configured interval.
23731
+
23581
23732
  @stable
23582
23733
  */
23583
23734
  var config = new up.Config(function () { return ({
@@ -23611,65 +23762,33 @@ up.radio = (function () {
23611
23762
  /*-
23612
23763
  Starts [polling](/up-poll) the given element.
23613
23764
 
23765
+ The given element does not need an `[up-poll]` attribute.
23766
+
23614
23767
  @function up.radio.startPolling
23615
- @param {Element|jQuery|string} fragment
23768
+ @param {Element} fragment
23616
23769
  The fragment to reload periodically.
23617
23770
  @param {number} options.interval
23618
23771
  The reload interval in milliseconds.
23619
23772
 
23620
23773
  Defaults to `up.radio.config.pollInterval`.
23774
+ @param {string} options.url
23775
+ Defaults to the element's closest `[up-source]` attribute.
23621
23776
  @stable
23622
23777
  */
23623
23778
  function startPolling(fragment, options) {
23624
- var _a, _b;
23625
23779
  if (options === void 0) { options = {}; }
23626
- var interval = (_b = ((_a = options.interval) !== null && _a !== void 0 ? _a : e.numberAttr(fragment, 'up-interval'))) !== null && _b !== void 0 ? _b : config.pollInterval;
23627
- var stopped = false;
23628
- var lastRequest = null;
23629
- options.onQueued = function (request) { return lastRequest = request; };
23630
- function doReload() {
23631
- // The setTimeout(doReload) callback might already be scheduled
23632
- // before the polling stopped.
23633
- if (stopped) {
23634
- return;
23635
- }
23636
- if (shouldPoll(fragment)) {
23637
- u.always(up.reload(fragment, options), doSchedule);
23638
- }
23639
- else {
23640
- up.puts('[up-poll]', 'Polling is disabled');
23641
- // Reconsider after 10 seconds at most
23642
- doSchedule(Math.min(10 * 1000, interval));
23643
- }
23644
- }
23645
- function doSchedule(delay) {
23646
- if (delay === void 0) { delay = interval; }
23647
- // The up.reload().then(doSchedule) callback might already be
23648
- // registered before the polling stopped.
23649
- if (stopped) {
23650
- return;
23651
- }
23652
- setTimeout(doReload, delay);
23653
- }
23654
- function destructor() {
23655
- stopped = true; // Don't execute already-scheduled callbacks
23656
- lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.abort(); // Abort any pending request
23657
- }
23658
- // up.radio.stopPolling() will emit up:poll:stop to signal cancelation.
23659
- up.on(fragment, 'up:poll:stop', destructor);
23660
- doSchedule();
23661
- return destructor;
23780
+ up.FragmentPolling.forFragment(fragment).forceStart(options);
23662
23781
  }
23663
23782
  /*-
23664
23783
  Stops [polling](/up-poll) the given element.
23665
23784
 
23666
23785
  @function up.radio.stopPolling
23667
- @param {Element|jQuery|string} fragment
23786
+ @param {Element} fragment
23668
23787
  The fragment to stop reloading.
23669
23788
  @stable
23670
23789
  */
23671
23790
  function stopPolling(element) {
23672
- up.emit(element, 'up:poll:stop');
23791
+ up.FragmentPolling.forFragment(element).forceStop();
23673
23792
  }
23674
23793
  function shouldPoll(fragment) {
23675
23794
  var _a, _b;
@@ -23721,7 +23840,17 @@ up.radio = (function () {
23721
23840
  </div>
23722
23841
  ```
23723
23842
 
23724
- ### Skipping updates when nothing changed
23843
+ ### Skipping updates on the client
23844
+
23845
+ Client-side code may skip an update by preventing an `up:fragment:poll` event
23846
+ on the polling fragment.
23847
+
23848
+ Unpoly will also choose to skip updates under certain conditions,
23849
+ e.g. when the browser tab is in the background. See `up.radio.config.pollEnabled` for details.
23850
+
23851
+ When an update is skipped, Unpoly will try to poll again after the configured interval.
23852
+
23853
+ ### Skipping updates on the server
23725
23854
 
23726
23855
  When polling a fragment periodically we want to avoid rendering unchanged content.
23727
23856
  This saves <b>CPU time</b> and reduces the <b>bandwidth cost</b> for a
@@ -23730,26 +23859,57 @@ up.radio = (function () {
23730
23859
  To achieve this we timestamp your fragments with an `[up-time]` attribute to indicate
23731
23860
  when the underlying data was last changed. See `[up-time]` for a detailed example.
23732
23861
 
23862
+ If the server has no more recent changes, it may skip the update by responding
23863
+ with an HTTP status `304 Not Modified`.
23864
+
23865
+ When an update is skipped, Unpoly will try to poll again after the configured interval.
23866
+
23867
+ ### Stopping polling
23868
+
23869
+ - The fragment from the server response no longer has an `[up-poll]` attribute.
23870
+ - Client-side code has called `up.radio.stopPolling()` with the polling element.
23871
+ - Polling was [disabled globally](/up.radio.config#config.pollEnabled).
23872
+
23733
23873
  @selector [up-poll]
23734
23874
  @param [up-interval]
23735
23875
  The reload interval in milliseconds.
23736
23876
 
23737
23877
  Defaults to `up.radio.config.pollInterval`.
23878
+ @param [up-source]
23879
+ The URL from which to reload the fragment.
23880
+
23881
+ Defaults to the closest `[up-source]` attribute of an ancestor element.
23738
23882
  @stable
23739
23883
  */
23740
- up.compiler('[up-poll]', startPolling);
23884
+ up.compiler('[up-poll]', function (fragment) {
23885
+ up.FragmentPolling.forFragment(fragment).onPollAttributeObserved();
23886
+ });
23887
+ /*-
23888
+ This event is emitted before a [polling](/up-poll) fragment is reloaded from the server.
23889
+
23890
+ Listener may prevent the `up:fragment:poll` event to prevent the fragment from being reloaded.
23891
+ Preventing the event will only skip a single update. It will *not* stop future polling.
23892
+
23893
+ @event up:fragment:poll
23894
+ @param {Element} event.target
23895
+ The polling fragment.
23896
+ @param event.preventDefault()
23897
+ Event listeners may call this method to prevent the fragment from being reloaded.
23898
+ @experimental
23899
+ */
23741
23900
  up.on('up:framework:reset', reset);
23742
23901
  return {
23743
23902
  config: config,
23744
23903
  hungrySelector: hungrySelector,
23745
23904
  startPolling: startPolling,
23746
- stopPolling: stopPolling
23905
+ stopPolling: stopPolling,
23906
+ shouldPoll: shouldPoll,
23747
23907
  };
23748
23908
  })();
23749
23909
 
23750
23910
 
23751
23911
  /***/ }),
23752
- /* 90 */
23912
+ /* 91 */
23753
23913
  /***/ (function() {
23754
23914
 
23755
23915
  /*
@@ -23889,15 +24049,16 @@ __webpack_require__(73);
23889
24049
  __webpack_require__(74);
23890
24050
  __webpack_require__(75);
23891
24051
  __webpack_require__(76);
23892
- __webpack_require__(78);
23893
- __webpack_require__(80);
24052
+ __webpack_require__(77);
24053
+ __webpack_require__(79);
23894
24054
  __webpack_require__(81);
23895
- __webpack_require__(83);
23896
- __webpack_require__(85);
23897
- __webpack_require__(87);
24055
+ __webpack_require__(82);
24056
+ __webpack_require__(84);
24057
+ __webpack_require__(86);
23898
24058
  __webpack_require__(88);
23899
24059
  __webpack_require__(89);
23900
24060
  __webpack_require__(90);
24061
+ __webpack_require__(91);
23901
24062
  up.framework.onEvaled();
23902
24063
 
23903
24064
  }();