-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonloadCSS.js
29 lines (27 loc) · 898 Bytes
/
onloadCSS.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*! onloadCSS: adds onload support for asynchronous stylesheets loaded with loadCSS. [c]2016 @zachleat, Filament Group, Inc. Licensed MIT */
/* global navigator */
/* exported onloadCSS */
function onloadCSS( ss, callback ) {
var called;
function newcb(){
if( !called && callback ){
called = true;
callback.call( ss );
}
}
if( ss.addEventListener ){
ss.addEventListener( "load", newcb );
}
if( ss.attachEvent ){
ss.attachEvent( "onload", newcb );
}
// This code is for browsers that don’t support onload
// No support for onload (it'll bind but never fire):
// * Android 4.3 (Samsung Galaxy S4, Browserstack)
// * Android 4.2 Browser (Samsung Galaxy SIII Mini GT-I8200L)
// * Android 2.3 (Pantech Burst P9070)
// Weak inference targets Android < 4.4
if( "isApplicationInstalled" in navigator && "onloadcssdefined" in ss ) {
ss.onloadcssdefined( newcb );
}
}