@@ -35,25 +35,29 @@ OTHER DEALINGS IN THE SOFTWARE.
3535import * as Backbone from 'backbone' ;
3636
3737// 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 ;
3940
4041// 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 ;
5761
5862interface IDOMEvent {
5963 eventName : string ;
0 commit comments