Skip to content

Commit

Permalink
feat(SwalComponent): fix compatibility with SweetAlert2 ^7.12.4 type …
Browse files Browse the repository at this point in the history
…definitions
  • Loading branch information
toverux committed Mar 5, 2018
1 parent 2cd26a2 commit e1a2b80
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/swal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ export class SwalComponent implements OnChanges, OnDestroy {
const promise = swal(options);

//=> Handle (confirm) and (cancel) @Outputs
// tslint:disable-next-line:no-string-literal
const useRejections = (options as { useRejections?: boolean }).useRejections;

promise.then(
result => {
// noinspection JSDeprecatedSymbols - support for old SweetAlert2 versions
if (options.useRejections) {
if (useRejections) {
this.confirm.emit(result);
} else if ('value' in result) {
this.confirm.emit(result.value);
Expand All @@ -221,8 +223,7 @@ export class SwalComponent implements OnChanges, OnDestroy {
}
},
err => {
// noinspection JSDeprecatedSymbols - support for old SweetAlert2 versions
if (options.useRejections) {
if (useRejections) {
this.cancel.emit(err);
}
}
Expand Down

0 comments on commit e1a2b80

Please sign in to comment.