scorm-again 3.0.4 → 3.0.5

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.
package/dist/scorm12.js CHANGED
@@ -1906,7 +1906,13 @@ this.Scorm12API = (function () {
1906
1906
  if (!scorm2004) {
1907
1907
  if (isFinalAttribute) {
1908
1908
  if (typeof attribute === "undefined" || !this.context.checkObjectHasProperty(refObject, attribute)) {
1909
- this.context.throwSCORMError(CMIElement, invalidErrorCode, invalidErrorMessage);
1909
+ if (attribute === "_children") {
1910
+ this.context.throwSCORMError(CMIElement, getErrorCode(this.context.errorCodes, "CHILDREN_ERROR"));
1911
+ } else if (attribute === "_count") {
1912
+ this.context.throwSCORMError(CMIElement, getErrorCode(this.context.errorCodes, "COUNT_ERROR"));
1913
+ } else {
1914
+ this.context.throwSCORMError(CMIElement, invalidErrorCode, invalidErrorMessage);
1915
+ }
1910
1916
  return {
1911
1917
  error: true
1912
1918
  };
@@ -3994,19 +4000,20 @@ ${stackTrace}`);
3994
4000
  if (errorCode === 143) returnValue = global_constants.SCORM_FALSE;
3995
4001
  } else {
3996
4002
  const result = this.storeData(false);
3997
- if ((result.errorCode ?? 0) > 0) {
4003
+ const errorCode = result.errorCode ?? 0;
4004
+ if (errorCode > 0) {
3998
4005
  if (result.errorMessage) {
3999
4006
  this.apiLog("commit", `Commit failed with error: ${result.errorMessage}`, LogLevelEnum.ERROR);
4000
4007
  }
4001
4008
  if (result.errorDetails) {
4002
4009
  this.apiLog("commit", `Error details: ${JSON.stringify(result.errorDetails)}`, LogLevelEnum.DEBUG);
4003
4010
  }
4004
- this.throwSCORMError("api", result.errorCode);
4011
+ this.throwSCORMError("api", errorCode);
4005
4012
  }
4006
4013
  const resultValue = result?.result ?? global_constants.SCORM_FALSE;
4007
4014
  returnValue = typeof resultValue === "boolean" ? String(resultValue) : resultValue;
4008
4015
  this.apiLog(callbackName, " Result: " + returnValue, LogLevelEnum.DEBUG, "HttpRequest");
4009
- if (checkTerminated) this.lastErrorCode = "0";
4016
+ if (checkTerminated && errorCode === 0) this.lastErrorCode = "0";
4010
4017
  this.processListeners(callbackName);
4011
4018
  if (this.settings.enableOfflineSupport && this._offlineStorageService && this._offlineStorageService.isDeviceOnline() && this._courseId) {
4012
4019
  this._offlineStorageService.hasPendingOfflineData(this._courseId).then(hasPendingData => {