@@ -24,22 +24,25 @@ define([
2424 has . add ( "highcontrast" , function ( ) {
2525 // note: if multiple documents, doesn't matter which one we use
2626 var div = win . doc . createElement ( "div" ) ;
27- div . style . cssText = "border: 1px solid; border-color:red green; position: absolute; height: 5px; top: -999px;" +
28- "background-image: url(\"" + ( config . blankGif || require . toUrl ( "./resources/blank.gif" ) ) + "\");" ;
29- win . body ( ) . appendChild ( div ) ;
30-
31- var cs = domStyle . getComputedStyle ( div ) ,
32- bkImg = cs . backgroundImage ,
33- hc = ( cs . borderTopColor == cs . borderRightColor ) ||
27+ try {
28+ div . style . cssText = "border: 1px solid; border-color:red green; position: absolute; height: 5px; top: -999px;" +
29+ "background-image: url(\"" + ( config . blankGif || require . toUrl ( "./resources/blank.gif" ) ) + "\");" ;
30+ win . body ( ) . appendChild ( div ) ;
31+
32+ var cs = domStyle . getComputedStyle ( div ) ,
33+ bkImg = cs . backgroundImage ;
34+ return cs . borderTopColor == cs . borderRightColor ||
3435 ( bkImg && ( bkImg == "none" || bkImg == "url(invalid-url:)" ) ) ;
35-
36- if ( has ( "ie" ) <= 8 ) {
37- div . outerHTML = "" ; // prevent mixed-content warning, see http://support.microsoft.com/kb/925014
38- } else {
39- win . body ( ) . removeChild ( div ) ;
36+ } catch ( e ) {
37+ console . warn ( "hccss: exception detecting high-contrast mode, document is likely hidden: " + e . toString ( ) ) ;
38+ return false ;
39+ } finally {
40+ if ( has ( "ie" ) <= 8 ) {
41+ div . outerHTML = "" ; // prevent mixed-content warning, see http://support.microsoft.com/kb/925014
42+ } else {
43+ win . body ( ) . removeChild ( div ) ;
44+ }
4045 }
41-
42- return hc ;
4346 } ) ;
4447
4548 domReady ( function ( ) {
0 commit comments