@@ -12,7 +12,7 @@ function isObject(what) {
1212// Yanked from https://git.io/vS8DV re-used under CC0
1313// with some tiny modifications
1414function isError ( value ) {
15- switch ( { } . toString . call ( value ) ) {
15+ switch ( Object . prototype . toString . call ( value ) ) {
1616 case '[object Error]' :
1717 return true ;
1818 case '[object Exception]' :
@@ -25,7 +25,15 @@ function isError(value) {
2525}
2626
2727function isErrorEvent ( value ) {
28- return supportsErrorEvent ( ) && { } . toString . call ( value ) === '[object ErrorEvent]' ;
28+ return Object . prototype . toString . call ( value ) === '[object ErrorEvent]' ;
29+ }
30+
31+ function isDOMError ( value ) {
32+ return Object . prototype . toString . call ( value ) === '[object DOMError]' ;
33+ }
34+
35+ function isDOMException ( value ) {
36+ return Object . prototype . toString . call ( value ) === '[object DOMException]' ;
2937}
3038
3139function isUndefined ( what ) {
@@ -68,6 +76,24 @@ function supportsErrorEvent() {
6876 }
6977}
7078
79+ function supportsDOMError ( ) {
80+ try {
81+ new DOMError ( '' ) ; // eslint-disable-line no-new
82+ return true ;
83+ } catch ( e ) {
84+ return false ;
85+ }
86+ }
87+
88+ function supportsDOMException ( ) {
89+ try {
90+ new DOMException ( '' ) ; // eslint-disable-line no-new
91+ return true ;
92+ } catch ( e ) {
93+ return false ;
94+ }
95+ }
96+
7197function supportsFetch ( ) {
7298 if ( ! ( 'fetch' in _window ) ) return false ;
7399
@@ -583,13 +609,17 @@ module.exports = {
583609 isObject : isObject ,
584610 isError : isError ,
585611 isErrorEvent : isErrorEvent ,
612+ isDOMError : isDOMError ,
613+ isDOMException : isDOMException ,
586614 isUndefined : isUndefined ,
587615 isFunction : isFunction ,
588616 isPlainObject : isPlainObject ,
589617 isString : isString ,
590618 isArray : isArray ,
591619 isEmptyObject : isEmptyObject ,
592620 supportsErrorEvent : supportsErrorEvent ,
621+ supportsDOMError : supportsDOMError ,
622+ supportsDOMException : supportsDOMException ,
593623 supportsFetch : supportsFetch ,
594624 supportsReferrerPolicy : supportsReferrerPolicy ,
595625 supportsPromiseRejectionEvent : supportsPromiseRejectionEvent ,
0 commit comments