Skip to content

Commit

Permalink
build min file
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Apr 16, 2024
1 parent 1c18786 commit 01b18e6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Options can be either passed to the constructor (eg: optionName) or in data-opti
| onFocus | [<code>EventCallback</code>](#EventCallback) | Callback function on focus |
| onCanAdd | [<code>AddCallback</code>](#AddCallback) | Callback function to validate item. Return false to show validation message. |
| onServerResponse | [<code>ServerCallback</code>](#ServerCallback) | Callback function to process server response. Must return a Promise |
| onServerError | [<code>ErrorCallback</code>](#ErrorCallback) | Callback function to process server errors. |
| confirmClear | [<code>ModalItemCallback</code>](#ModalItemCallback) | Allow modal confirmation of clear. Must return a Promise |
| confirmAdd | [<code>ModalItemCallback</code>](#ModalItemCallback) | Allow modal confirmation of add. Must return a Promise |

Expand All @@ -166,6 +167,16 @@ To know more about these features, check the demo!
| -------- | --------------------- |
| response | <code>Response</code> |

<a name="ErrorCallback"></a>

## ErrorCallback ⇒ <code>void</code>

| Param | Type |
| ------ | -------------------------- |
| e | <code>Error</code> |
| signal | <code>AbortSignal</code> |
| inst | [<code>Tags</code>](#Tags) |

<a name="ModalItemCallback"></a>

### ModalItemCallback ⇒ <code>Promise</code>
Expand Down
22 changes: 17 additions & 5 deletions tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
* @returns {Promise}
*/

/**
* @callback ErrorCallback
* @param {Error} e
* @param {AbortSignal} signal
* @param {Tags} inst
* @returns {void}
*/

/**
* @callback ModalItemCallback
* @param {String} value
Expand Down Expand Up @@ -129,6 +137,7 @@
* @property {EventCallback} onFocus Callback function on focus
* @property {AddCallback} onCanAdd Callback function to validate item. Return false to show validation message.
* @property {ServerCallback} onServerResponse Callback function to process server response. Must return a Promise
* @property {ErrorCallback} onServerError Callback function to process server errors.
* @property {ModalItemCallback} confirmClear Allow modal confirmation of clear. Must return a Promise
* @property {ModalItemCallback} confirmAdd Allow modal confirmation of add. Must return a Promise
*/
Expand Down Expand Up @@ -218,6 +227,13 @@ const DEFAULTS = {
onServerResponse: (response, inst) => {
return response.json();
},
onServerError: (e, signal, inst) => {
// Current version of Firefox rejects the promise with a DOMException
if (e.name === "AbortError" || signal.aborted) {
return;
}
console.error(e);
},
};

// #endregion
Expand Down Expand Up @@ -1241,11 +1257,7 @@ class Tags {
}
})
.catch((e) => {
// Current version of Firefox rejects the promise with a DOMException
if (e.name === "AbortError" || this._abortController.signal.aborted) {
return;
}
console.error(e);
this._config.onServerError(e, this._abortController.signal, this);
})
.finally((e) => {
this._holderElement.classList.remove(LOADING_CLASS);
Expand Down
Loading

0 comments on commit 01b18e6

Please sign in to comment.