File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 3
3
* Copyright 2010-2014 John-David Dalton <http://allyoucanleet.com/>
4
4
* Available under MIT license <http://mths.be/mit>
5
5
*/
6
- ; ( function ( root ) {
6
+ ; ( function ( ) {
7
7
'use strict' ;
8
8
9
- /** Backup possible global object */
10
- var oldRoot = root ;
11
-
12
9
/** Used to determine if values are of the language type Object */
13
10
var objectTypes = {
14
- 'boolean' : false ,
15
11
'function' : true ,
16
- 'object' : true ,
17
- 'number' : false ,
18
- 'string' : false ,
19
- 'undefined' : false
12
+ 'object' : true
20
13
} ;
21
14
15
+ /** Used as a reference to the global object */
16
+ var root = ( objectTypes [ typeof window ] && window ) || this ;
17
+
18
+ /** Backup possible global object */
19
+ var oldRoot = root ;
20
+
22
21
/** Detect free variable `exports` */
23
22
var freeExports = objectTypes [ typeof exports ] && exports ;
24
23
25
- /** Detect free variable `global` */
24
+ /** Detect free variable `global`, from Node.js or Browserified code, and use it as `root` */
26
25
var freeGlobal = objectTypes [ typeof global ] && global ;
27
26
if ( freeGlobal && ( freeGlobal . global === freeGlobal || freeGlobal . window === freeGlobal ) ) {
28
27
root = freeGlobal ;
1016
1015
else {
1017
1016
root . platform = parse ( ) ;
1018
1017
}
1019
- } ( this ) ) ;
1018
+ } . call ( this ) ) ;
Original file line number Diff line number Diff line change 127
127
return Function ( 'options' ,
128
128
( 'return ' +
129
129
/ \( f u n c t i o n [ \s \S ] + ?(? = i f \s * \( t y p e o f d e f i n e ) / . exec ( code ) [ 0 ] +
130
- ' return parse()}(this))' )
130
+ ' return parse()}.call (this))' )
131
131
. replace ( '/internal|\\n/i.test(toString.toString())' , '!me.likeChrome' )
132
- . replace ( / ( f u n c t i o n \s * \( \s * r o o t \s * \) [ ^ \n ] + \n ) / , '$1me=options;\n' )
132
+ . replace ( / \b r o o t \s * = [ ^ \n ] + ?( ; \n ) / , 'root=options$1' )
133
+ . replace ( / \b o l d R o o t \s * = [ ^ \n ] + ?( ; \n ) / , 'oldRoot=options$1' )
133
134
. replace ( / \b v a r t h i s B i n d i n g \s * = [ ^ \n ] + ?( ; \n ) / , '' )
134
- . replace ( / \b o l d W i n \s * = [ ^ \n ] + ?( ; \n ) / , 'oldWin=options$1' )
135
- . replace ( / \b f r e e G l o b a l \s * = (?: .| \n ) + ?( ; \n ) / , 'freeGlobal=options.global$1' )
135
+ . replace ( / \b f r e e G l o b a l \s * = (?: .| \n ) + ?( ; \n ) \s * i f [ ^ } ] + \} / , 'freeGlobal=options.global$1' )
136
136
. replace ( / \b u s e r A g e n t \s * = [ ^ \n ] + ?( ; \n ) / , 'userAgent=me.ua$1' )
137
137
. replace ( / \b (?: t h i s B i n d i n g | r o o t ) \b / g, 'me' )
138
138
. replace ( / ( [ ^ . ] ) \b s y s t e m \b / g, '$1me.system' )
You can’t perform that action at this time.
0 commit comments