jsf.js_next_gen 4.0.0-beta-15 → 4.0.0-beta-16

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.
@@ -7035,13 +7035,11 @@ class XhrRequest {
7035
7035
  }, data);
7036
7036
  }
7037
7037
  catch(func) {
7038
- //this.$promise.catch(func);
7039
7038
  this.catchFuncs.push(func);
7040
7039
  return this;
7041
7040
  }
7042
7041
  finally(func) {
7043
7042
  //no ie11 support we probably are going to revert to shims for that one
7044
- //(<any>this.$promise).then(func).catch(func);
7045
7043
  this.catchFuncs.push(func);
7046
7044
  this.thenFunc.push(func);
7047
7045
  return this;
@@ -7073,15 +7071,32 @@ class XhrRequest {
7073
7071
  this.onDone(this.xhrObject, resolve);
7074
7072
  };
7075
7073
  xhrObject.onerror = (errorData) => {
7074
+ // some browsers trigger an error when cancelling a request internally
7075
+ // in this case we simply ignore the request and clear up the queue, because
7076
+ // it is not safe anymore to proceed with the current queue
7077
+ // This bypasses a Safari issue where it keeps requests hanging after page unload
7078
+ // and then triggers a cancel error on then instead of just stopping
7079
+ // and clearing the code
7080
+ if (this.isCancelledResponse(this.xhrObject)) {
7081
+ reject();
7082
+ this.stopProgress = true;
7083
+ return;
7084
+ }
7076
7085
  this.onError(errorData, reject);
7077
7086
  };
7078
7087
  }
7088
+ isCancelledResponse(currentTarget) {
7089
+ return (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.status) === 0 && //cancelled by browser
7090
+ (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.readyState) === 4 &&
7091
+ (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.responseText) === '' &&
7092
+ (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.responseXML) === null;
7093
+ }
7079
7094
  /*
7080
- * xhr processing callbacks
7081
- *
7082
- * Those methods are the callbacks called by
7083
- * the xhr object depending on its own state
7084
- */
7095
+ * xhr processing callbacks
7096
+ *
7097
+ * Those methods are the callbacks called by
7098
+ * the xhr object depending on its own state
7099
+ */
7085
7100
  onAbort(reject) {
7086
7101
  reject();
7087
7102
  }
@@ -7115,13 +7130,14 @@ class XhrRequest {
7115
7130
  this.handleError(errorData, true);
7116
7131
  }
7117
7132
  finally {
7118
- //we issue a resolve in this case to allow the system to recover
7133
+ // we issue a resolve in this case to allow the system to recover
7134
+ // reject would clean up the queue
7119
7135
  resolve(errorData);
7120
- //reject();
7121
7136
  }
7122
7137
  //non blocking non clearing
7123
7138
  }
7124
7139
  onDone(data, resolve) {
7140
+ // if stop progress a special handling including resolve is already performed
7125
7141
  if (this.stopProgress) {
7126
7142
  return;
7127
7143
  }
@@ -7150,7 +7166,7 @@ class XhrRequest {
7150
7166
  try {
7151
7167
  //user code error, we might cover
7152
7168
  //this in onError but also we cannot swallow it
7153
- //we need to resolve the local handlers lazyly,
7169
+ //we need to resolve the local handlers lazily,
7154
7170
  //because some frameworks might decorate them over the context in the response
7155
7171
  let eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_EVENT);
7156
7172
  AjaxImpl_1.Implementation.sendEvent(eventData, eventHandler);
Binary file
Binary file