@@ -35,25 +35,29 @@ OTHER DEALINGS IN THE SOFTWARE.
35
35
import * as Backbone from 'backbone' ;
36
36
37
37
// Caches a local reference to `Element.prototype` for faster access.
38
- const ElementProto : any = Element . prototype ; // : typeof Element = (typeof Element !== 'undefined' && Element.prototype) || {};
38
+ const ElementProto : any =
39
+ typeof Element !== 'undefined' ? Element . prototype : undefined ;
39
40
40
41
// Find the right `Element#matches` for IE>=9 and modern browsers.
41
- const matchesSelector =
42
- ElementProto . matches ||
43
- ElementProto [ 'webkitMatchesSelector' ] ||
44
- ElementProto [ 'mozMatchesSelector' ] ||
45
- ElementProto [ 'msMatchesSelector' ] ||
46
- ElementProto [ 'oMatchesSelector' ] ||
47
- function matches ( selector : string ) : boolean {
48
- const matches = ( this . document || this . ownerDocument ) . querySelectorAll (
49
- selector
50
- ) ;
51
- let i = matches . length ;
52
- while ( -- i >= 0 && matches . item ( i ) !== this ) {
53
- continue ;
54
- }
55
- return i > - 1 ;
56
- } ;
42
+ function matchesFallback ( selector : string ) : boolean {
43
+ const matches = ( this . document || this . ownerDocument ) . querySelectorAll (
44
+ selector
45
+ ) ;
46
+ let i = matches . length ;
47
+ while ( -- i >= 0 && matches . item ( i ) !== this ) {
48
+ continue ;
49
+ }
50
+ return i > - 1 ;
51
+ }
52
+
53
+ const matchesSelector = ElementProto
54
+ ? ElementProto . matches ||
55
+ ElementProto [ 'webkitMatchesSelector' ] ||
56
+ ElementProto [ 'mozMatchesSelector' ] ||
57
+ ElementProto [ 'msMatchesSelector' ] ||
58
+ ElementProto [ 'oMatchesSelector' ] ||
59
+ matchesFallback
60
+ : matchesFallback ;
57
61
58
62
interface IDOMEvent {
59
63
eventName : string ;
0 commit comments