UNPKG

sweetalert2

Version:

A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert

20 lines (19 loc) 644 B
/** * Extends a Swal class making it able to be instantiated without the `new` keyword (and thus without `Swal.fire`) * @param ParentSwal * @returns {NoNewKeywordSwal} */ export function withNoNewKeyword (ParentSwal) { const NoNewKeywordSwal = function (...args) { if (!(this instanceof NoNewKeywordSwal)) { return new NoNewKeywordSwal(...args) } Object.getPrototypeOf(NoNewKeywordSwal).apply(this, args) } NoNewKeywordSwal.prototype = Object.assign( Object.create(ParentSwal.prototype), { constructor: NoNewKeywordSwal } ) Object.setPrototypeOf(NoNewKeywordSwal, ParentSwal) return NoNewKeywordSwal }