@@ -1352,14 +1352,31 @@ License: MIT License (see homepage)
1352
1352
__cache_object = WINDOW . localStorage ;
1353
1353
clearBrowserCache = function ( )
1354
1354
{
1355
- __cache_object . clear ( ) ;
1355
+ // cherry-pick only our own items in the cache
1356
+ for ( var key in __cache_object )
1357
+ {
1358
+ if ( key . indexOf ( ECSSTENDER ) === 0 )
1359
+ {
1360
+ delete ( __cache_object [ key ] ) ;
1361
+ }
1362
+ }
1356
1363
} ;
1357
1364
readFromBrowserCache = function ( cache , key )
1358
1365
{
1366
+ // make sure our cached objects are prefixed
1367
+ if ( cache != ECSSTENDER )
1368
+ {
1369
+ cache = ECSSTENDER + HYPHEN + cache ;
1370
+ }
1359
1371
return __cache_object . getItem ( cache + HYPHEN + key ) ;
1360
1372
} ;
1361
1373
writeToBrowserCache = function ( cache , key , value )
1362
1374
{
1375
+ // make sure our cached objects are prefixed
1376
+ if ( cache != ECSSTENDER )
1377
+ {
1378
+ cache = ECSSTENDER + HYPHEN + cache ;
1379
+ }
1363
1380
__cache_object . setItem ( cache + HYPHEN + key , value ) ;
1364
1381
} ;
1365
1382
}
@@ -1406,38 +1423,45 @@ License: MIT License (see homepage)
1406
1423
{
1407
1424
if ( __no_cache || __local ) { return ; }
1408
1425
enableCache ( ) ;
1409
- var cache_group , item , count ;
1410
- for ( cache_group in __local_cache )
1426
+ var cache_group , item , count ,
1427
+ version = 'version' ,
1428
+ cache_version = readFromBrowserCache ( ECSSTENDER , version ) ;
1429
+ // only use the cache if it was created from the same version of eCSStender
1430
+ // this allows us to tweak the cache going forward
1431
+ if ( cache_version == eCSStender [ version ] )
1411
1432
{
1412
- if ( ! isInheritedProperty ( __local_cache , cache_group ) &&
1413
- defined ( cache_group ) )
1433
+ for ( cache_group in __local_cache )
1414
1434
{
1415
- count = readFromBrowserCache ( ECSSTENDER , cache_group + COUNT ) ;
1416
- if ( defined ( count ) )
1435
+ if ( ! isInheritedProperty ( __local_cache , cache_group ) &&
1436
+ defined ( cache_group ) )
1417
1437
{
1418
- if ( cache_group == EXTENSION )
1438
+ count = readFromBrowserCache ( ECSSTENDER , cache_group + COUNT ) ;
1439
+ if ( defined ( count ) )
1419
1440
{
1420
- __t_count = count ;
1421
- if ( count < 1 ) { eCSStender . cache = FALSE ; }
1422
- }
1423
- while ( count >= 0 )
1424
- {
1425
- item = readFromBrowserCache ( cache_group , count ) ;
1426
- if ( item != NULL )
1441
+ if ( cache_group == EXTENSION )
1427
1442
{
1428
- if ( cache_group == EXTENSION )
1429
- {
1430
- __local_cache [ cache_group ] [ EXTENSION + count ] = item ;
1431
- }
1432
- else
1443
+ __t_count = count ;
1444
+ if ( count < 1 ) { eCSStender . cache = FALSE ; }
1445
+ }
1446
+ while ( count >= 0 )
1447
+ {
1448
+ item = readFromBrowserCache ( cache_group , count ) ;
1449
+ if ( item != NULL )
1433
1450
{
1434
- item = item . split ( PIPES ) ;
1435
- if ( item [ 1 ] == 'true' ) { item [ 1 ] = TRUE ; }
1436
- if ( item [ 1 ] == 'false' ) { item [ 1 ] = FALSE ; }
1437
- __local_cache [ cache_group ] [ item [ 0 ] ] = item [ 1 ] ;
1451
+ if ( cache_group == EXTENSION )
1452
+ {
1453
+ __local_cache [ cache_group ] [ EXTENSION + count ] = item ;
1454
+ }
1455
+ else
1456
+ {
1457
+ item = item . split ( PIPES ) ;
1458
+ if ( item [ 1 ] == 'true' ) { item [ 1 ] = TRUE ; }
1459
+ if ( item [ 1 ] == 'false' ) { item [ 1 ] = FALSE ; }
1460
+ __local_cache [ cache_group ] [ item [ 0 ] ] = item [ 1 ] ;
1461
+ }
1438
1462
}
1463
+ count -- ;
1439
1464
}
1440
- count -- ;
1441
1465
}
1442
1466
}
1443
1467
}
@@ -1475,6 +1499,7 @@ License: MIT License (see homepage)
1475
1499
writeToBrowserCache ( ECSSTENDER , cache_group + COUNT , count ) ;
1476
1500
}
1477
1501
}
1502
+ writeToBrowserCache ( ECSSTENDER , 'version' , eCSStender . version ) ;
1478
1503
__cached_out = TRUE ;
1479
1504
}
1480
1505
function styleObjToString ( obj )
0 commit comments