@@ -154,6 +154,12 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
154
154
155
155
} )
156
156
} ) ;
157
+
158
+ BASE . Object . isArray = Array . isArray || function ( obj ) {
159
+ return Object . prototype . toString . call ( obj ) === "[object Array]" ;
160
+ } ;
161
+
162
+ BASE . Object . Array = Array ;
157
163
158
164
} ) ( "MathJax" ) ;
159
165
@@ -211,6 +217,7 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
211
217
( function ( BASENAME ) {
212
218
var BASE = window [ BASENAME ] ;
213
219
if ( ! BASE ) { BASE = window [ BASENAME ] = { } }
220
+ var isArray = BASE . Object . isArray ;
214
221
//
215
222
// Create a callback from an associative array
216
223
//
@@ -279,8 +286,8 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
279
286
}
280
287
}
281
288
TESTEVAL = null ;
282
- }
283
-
289
+ } ;
290
+
284
291
//
285
292
// Create a callback from various types of data
286
293
//
@@ -291,11 +298,11 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
291
298
{ args = [ ] . slice . call ( args , i ) }
292
299
else { args = [ ] . slice . call ( arguments , 0 ) }
293
300
}
294
- if ( args instanceof Array && args . length === 1 ) { args = args [ 0 ] }
301
+ if ( isArray ( args ) && args . length === 1 ) { args = args [ 0 ] }
295
302
if ( typeof args === 'function' ) {
296
303
if ( args . execute === CALLBACK . prototype . execute ) { return args }
297
304
return CALLBACK ( { hook : args } ) ;
298
- } else if ( args instanceof Array ) {
305
+ } else if ( isArray ( args ) ) {
299
306
if ( typeof ( args [ 0 ] ) === 'string' && args [ 1 ] instanceof Object &&
300
307
typeof args [ 1 ] [ args [ 0 ] ] === 'function' ) {
301
308
return CALLBACK ( { hook : args [ 1 ] [ args [ 0 ] ] , object : args [ 1 ] , data : args . slice ( 2 ) } ) ;
@@ -343,7 +350,7 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
343
350
}
344
351
} ;
345
352
var WAITSIGNAL = function ( callback , signals ) {
346
- if ( ! ( signals instanceof Array ) ) { signals = [ signals ] }
353
+ if ( ! isArray ( signals ) ) { signals = [ signals ] }
347
354
if ( ! callback . signal ) {
348
355
callback . oldExecute = callback . execute ;
349
356
callback . execute = WAITEXECUTE ;
@@ -442,8 +449,8 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
442
449
//
443
450
var EXECUTEHOOKS = function ( hooks , data , reset ) {
444
451
if ( ! hooks ) { return null }
445
- if ( ! ( hooks instanceof Array ) ) { hooks = [ hooks ] }
446
- if ( ! ( data instanceof Array ) ) { data = ( data == null ? [ ] : [ data ] ) }
452
+ if ( ! isArray ( hooks ) ) { hooks = [ hooks ] }
453
+ if ( ! isArray ( data ) ) { data = ( data == null ? [ ] : [ data ] ) }
447
454
var handler = HOOKS ( reset ) ;
448
455
for ( var i = 0 , m = hooks . length ; i < m ; i ++ ) { handler . Add ( hooks [ i ] ) }
449
456
return handler . Execute . apply ( handler , data ) ;
@@ -592,7 +599,7 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
592
599
// Execute the message hooks for the given message
593
600
//
594
601
ExecuteHooks : function ( msg ) {
595
- var type = ( ( msg instanceof Array ) ? msg [ 0 ] : msg ) ;
602
+ var type = ( isArray ( msg ) ? msg [ 0 ] : msg ) ;
596
603
if ( ! this . hooks [ type ] ) { return null }
597
604
return this . hooks [ type ] . Execute ( msg ) ;
598
605
} ,
@@ -1003,7 +1010,7 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
1003
1010
for ( id in styles ) { if ( styles . hasOwnProperty ( id ) ) {
1004
1011
if ( typeof styles [ id ] === 'string' ) {
1005
1012
string += id + " {" + styles [ id ] + "}\n" ;
1006
- } else if ( styles [ id ] instanceof Array ) {
1013
+ } else if ( BASE . Object . isArray ( styles [ id ] ) ) {
1007
1014
for ( var i = 0 ; i < styles [ id ] . length ; i ++ ) {
1008
1015
style = { } ; style [ id ] = styles [ id ] [ i ] ;
1009
1016
string += this . StyleString ( style ) ;
@@ -1055,9 +1062,9 @@ MathJax.HTML = {
1055
1062
}
1056
1063
}
1057
1064
if ( contents ) {
1058
- if ( ! ( contents instanceof Array ) ) { contents = [ contents ] }
1065
+ if ( ! MathJax . Object . isArray ( contents ) ) { contents = [ contents ] }
1059
1066
for ( var i = 0 , m = contents . length ; i < m ; i ++ ) {
1060
- if ( contents [ i ] instanceof Array ) {
1067
+ if ( MathJax . Object . isArray ( contents [ i ] ) ) {
1061
1068
obj . appendChild ( this . Element ( contents [ i ] [ 0 ] , contents [ i ] [ 1 ] , contents [ i ] [ 2 ] ) ) ;
1062
1069
} else if ( type === "script" ) { // IE throws an error if script is added as a text node
1063
1070
this . setScript ( obj , contents [ i ] ) ;
@@ -1220,7 +1227,7 @@ MathJax.Localization = {
1220
1227
} ) ,
1221
1228
1222
1229
_ : function ( id , phrase ) {
1223
- if ( phrase instanceof Array ) { return this . processSnippet ( id , phrase ) }
1230
+ if ( MathJax . Object . isArray ( phrase ) ) { return this . processSnippet ( id , phrase ) }
1224
1231
return this . processString ( this . lookupPhrase ( id , phrase ) , [ ] . slice . call ( arguments , 2 ) ) ;
1225
1232
} ,
1226
1233
@@ -1230,9 +1237,9 @@ MathJax.Localization = {
1230
1237
// If the argument is a snippet (and we are processing snippets) do so,
1231
1238
// Otherwise, if it is a number, convert it for the lacale
1232
1239
//
1233
- var i , m ;
1240
+ var i , m , isArray = MathJax . Object . isArray ;
1234
1241
for ( i = 0 , m = args . length ; i < m ; i ++ ) {
1235
- if ( domain && args [ i ] instanceof Array ) { args [ i ] = this . processSnippet ( domain , args [ i ] ) }
1242
+ if ( domain && isArray ( args [ i ] ) ) { args [ i ] = this . processSnippet ( domain , args [ i ] ) }
1236
1243
}
1237
1244
//
1238
1245
// Split string at escapes and process them individually
@@ -1282,7 +1289,7 @@ MathJax.Localization = {
1282
1289
for ( i = 0 ; i < m ; i ++ ) {
1283
1290
part += parts [ i ] ; i ++ ; // add the string and move on to substitution result
1284
1291
if ( i < m ) {
1285
- if ( parts [ i ] instanceof Array ) { // substitution was a snippet
1292
+ if ( isArray ( parts [ i ] ) ) { // substitution was a snippet
1286
1293
snippet . push ( part ) ; // add the accumulated string
1287
1294
snippet = snippet . concat ( parts [ i ] ) ; // concatenate the substution snippet
1288
1295
part = "" ; // start accumulating a new string
@@ -1302,18 +1309,18 @@ MathJax.Localization = {
1302
1309
// strings or snippets to translate
1303
1310
//
1304
1311
for ( var i = 0 , m = snippet . length ; i < m ; i ++ ) {
1305
- if ( snippet [ i ] instanceof Array ) {
1312
+ if ( MathJax . Object . isArray ( snippet [ i ] ) ) {
1306
1313
//
1307
1314
// This could be a sub-snippet:
1308
1315
// ["tag"] or ["tag",{properties}] or ["tag",{properties},snippet]
1309
1316
// Or it could be something to translate:
1310
1317
// [id,string,args] or [domain,snippet]
1311
1318
var data = snippet [ i ] ;
1312
1319
if ( typeof data [ 1 ] === "string" ) { // [id,string,args]
1313
- var id = data [ 0 ] ; if ( ! ( id instanceof Array ) ) { id = [ domain , id ] }
1320
+ var id = data [ 0 ] ; if ( ! MathJax . Object . isArray ( id ) ) { id = [ domain , id ] }
1314
1321
var phrase = this . lookupPhrase ( id , data [ 1 ] ) ;
1315
1322
result = result . concat ( this . processMarkdown ( phrase , data . slice ( 2 ) , domain ) ) ;
1316
- } else if ( data [ 1 ] instanceof Array ) { // [domain,snippet]
1323
+ } else if ( MathJax . Object . isArray ( data [ 1 ] ) ) { // [domain,snippet]
1317
1324
result = result . concat ( this . processSnippet . apply ( this , data ) ) ;
1318
1325
} else if ( data . length >= 3 ) { // ["tag",{properties},snippet]
1319
1326
result . push ( [ data [ 0 ] , data [ 1 ] , this . processSnippet ( domain , data [ 2 ] ) ] ) ;
@@ -1349,7 +1356,7 @@ MathJax.Localization = {
1349
1356
// Select the tag to use by number of stars (three stars requires two tags)
1350
1357
//
1351
1358
data = this . processString ( parts [ i + 2 ] , args , domain ) ;
1352
- if ( ! ( data instanceof Array ) ) { data = [ data ] }
1359
+ if ( ! MathJax . Object . isArray ( data ) ) { data = [ data ] }
1353
1360
data = [ [ "b" , "i" , "i" ] [ parts [ i + 1 ] . length - 1 ] , { } , data ] ; // number of stars determines type
1354
1361
if ( parts [ i + 1 ] . length === 3 ) { data = [ "b" , { } , data ] } // bold-italic
1355
1362
} else if ( parts [ i + 3 ] ) { // backtics (for code)
@@ -1358,14 +1365,14 @@ MathJax.Localization = {
1358
1365
// Make a <code> tag
1359
1366
//
1360
1367
data = this . processString ( parts [ i + 4 ] . replace ( / ^ \s / , "" ) . replace ( / \s $ / , "" ) , args , domain ) ;
1361
- if ( ! ( data instanceof Array ) ) { data = [ data ] }
1368
+ if ( ! MathJax . Object . isArray ( data ) ) { data = [ data ] }
1362
1369
data = [ "code" , { } , data ] ;
1363
1370
} else if ( parts [ i + 5 ] ) { // hyperlink
1364
1371
//
1365
1372
// Process the link text, and make an <a> tag with the URL
1366
1373
//
1367
1374
data = this . processString ( parts [ i + 5 ] , args , domain ) ;
1368
- if ( ! ( data instanceof Array ) ) { data = [ data ] }
1375
+ if ( ! MathJax . Object . isArray ( data ) ) { data = [ data ] }
1369
1376
data = [ "a" , { href :this . processString ( parts [ i + 6 ] , args ) , target :"_blank" } , data ] ;
1370
1377
} else {
1371
1378
//
@@ -1400,7 +1407,7 @@ MathJax.Localization = {
1400
1407
// Then concatenate the snippet to the current one
1401
1408
//
1402
1409
string = this . processString ( string , args , domain ) ;
1403
- if ( ! ( string instanceof Array ) ) { string = [ string ] }
1410
+ if ( ! MathJax . Object . isArray ( string ) ) { string = [ string ] }
1404
1411
result = result . concat ( string ) ;
1405
1412
}
1406
1413
return result ;
@@ -1411,7 +1418,7 @@ MathJax.Localization = {
1411
1418
// Get the domain and messageID
1412
1419
//
1413
1420
if ( ! domain ) { domain = "_" }
1414
- if ( id instanceof Array ) { domain = ( id [ 0 ] || "_" ) ; id = ( id [ 1 ] || "" ) }
1421
+ if ( MathJax . Object . isArray ( id ) ) { domain = ( id [ 0 ] || "_" ) ; id = ( id [ 1 ] || "" ) }
1415
1422
//
1416
1423
// Check if the data is available and if not,
1417
1424
// load it and throw a restart error so the calling
@@ -1725,8 +1732,8 @@ MathJax.Message = {
1725
1732
// Translate message if it is [id,message,arguments]
1726
1733
//
1727
1734
var id = "" ;
1728
- if ( text instanceof Array ) {
1729
- id = text [ 0 ] ; if ( id instanceof Array ) { id = id [ 1 ] }
1735
+ if ( MathJax . Object . isArray ( text ) ) {
1736
+ id = text [ 0 ] ; if ( MathJax . Object . isArray ( id ) ) { id = id [ 1 ] }
1730
1737
//
1731
1738
// Localization._() will throw a restart error if a localization file
1732
1739
// needs to be loaded, so trap that and redo the Set() call
@@ -2411,11 +2418,11 @@ MathJax.Hub = {
2411
2418
} ,
2412
2419
2413
2420
elementCallback : function ( element , callback ) {
2414
- if ( callback == null && ( element instanceof Array || typeof element === 'function' ) )
2421
+ if ( callback == null && ( MathJax . Object . isArray ( element ) || typeof element === 'function' ) )
2415
2422
{ try { MathJax . Callback ( element ) ; callback = element ; element = null } catch ( e ) { } }
2416
2423
if ( element == null ) { element = this . config . elements || [ ] }
2417
2424
if ( this . isHTMLCollection ( element ) ) { element = this . HTMLCollection2Array ( element ) }
2418
- if ( ! ( element instanceof Array ) ) { element = [ element ] }
2425
+ if ( ! MathJax . Object . isArray ( element ) ) { element = [ element ] }
2419
2426
element = [ ] . concat ( element ) ; // make a copy so the original isn't changed
2420
2427
for ( var i = 0 , m = element . length ; i < m ; i ++ )
2421
2428
{ if ( typeof ( element [ i ] ) === 'string' ) { element [ i ] = document . getElementById ( element [ i ] ) } }
@@ -2431,7 +2438,7 @@ MathJax.Hub = {
2431
2438
2432
2439
elementScripts : function ( element ) {
2433
2440
var scripts = [ ] ;
2434
- if ( element instanceof Array || this . isHTMLCollection ( element ) ) {
2441
+ if ( MathJax . Object . isArray ( element ) || this . isHTMLCollection ( element ) ) {
2435
2442
for ( var i = 0 , m = element . length ; i < m ; i ++ ) {
2436
2443
var alreadyDone = 0 ;
2437
2444
for ( var j = 0 ; j < i && ! alreadyDone ; j ++ )
@@ -2468,7 +2475,7 @@ MathJax.Hub = {
2468
2475
Insert : function ( dst , src ) {
2469
2476
for ( var id in src ) { if ( src . hasOwnProperty ( id ) ) {
2470
2477
// allow for concatenation of arrays?
2471
- if ( typeof src [ id ] === 'object' && ! ( src [ id ] instanceof Array ) &&
2478
+ if ( typeof src [ id ] === 'object' && ! ( MathJax . Object . isArray ( src [ id ] ) ) &&
2472
2479
( typeof dst [ id ] === 'object' || typeof dst [ id ] === 'function' ) ) {
2473
2480
this . Insert ( dst [ id ] , src [ id ] ) ;
2474
2481
} else {
@@ -2785,7 +2792,7 @@ MathJax.Hub.Startup = {
2785
2792
//
2786
2793
loadArray : function ( files , dir , name , synchronous ) {
2787
2794
if ( files ) {
2788
- if ( ! ( files instanceof Array ) ) { files = [ files ] }
2795
+ if ( ! MathJax . Object . isArray ( files ) ) { files = [ files ] }
2789
2796
if ( files . length ) {
2790
2797
var queue = MathJax . Callback . Queue ( ) , callback = { } , file ;
2791
2798
for ( var i = 0 , m = files . length ; i < m ; i ++ ) {
@@ -2895,11 +2902,11 @@ MathJax.Hub.Startup = {
2895
2902
Process : function ( script , state ) {
2896
2903
var queue = CALLBACK . Queue ( ) , file ;
2897
2904
// Load any needed element jax
2898
- var jax = this . elementJax ; if ( ! ( jax instanceof Array ) ) { jax = [ jax ] }
2905
+ var jax = this . elementJax ; if ( ! BASE . Object . isArray ( jax ) ) { jax = [ jax ] }
2899
2906
for ( var i = 0 , m = jax . length ; i < m ; i ++ ) {
2900
2907
file = BASE . ElementJax . directory + "/" + jax [ i ] + "/" + this . JAXFILE ;
2901
2908
if ( ! this . require ) { this . require = [ ] }
2902
- else if ( ! ( this . require instanceof Array ) ) { this . require = [ this . require ] } ;
2909
+ else if ( ! BASE . Object . isArray ( this . require ) ) { this . require = [ this . require ] } ;
2903
2910
this . require . push ( file ) ; // so Startup will wait for it to be loaded
2904
2911
queue . Push ( AJAX . Require ( file ) ) ;
2905
2912
}
@@ -2954,7 +2961,7 @@ MathJax.Hub.Startup = {
2954
2961
{ jax [ mimetype ] . unshift ( this ) } else { jax [ mimetype ] . push ( this ) }
2955
2962
// Make sure the element jax is loaded before Startup is called
2956
2963
if ( ! this . require ) { this . require = [ ] }
2957
- else if ( ! ( this . require instanceof Array ) ) { this . require = [ this . require ] } ;
2964
+ else if ( ! BASE . Object . isArray ( this . require ) ) { this . require = [ this . require ] } ;
2958
2965
this . require . push ( BASE . ElementJax . directory + "/" + ( mimetype . split ( / \/ / ) [ 1 ] ) + "/" + this . JAXFILE ) ;
2959
2966
} ,
2960
2967
Remove : function ( jax ) { }
0 commit comments