Permalink
Browse files

Access window.PIE directly within init and cleanup functions rather t…

…han setting a variable in outer scope; this fixes an intermittent bug where init would be called before the outer var had its value set (due to the init function getting hoisted perhaps?) which led to elements not being initialized and, it seems, browser crashes.
  • Loading branch information...
1 parent f51449e commit c5ecdd754d48632253ed9f1569d7cc74124bd489 Jason Johnston committed Aug 8, 2011
Showing with 8 additions and 7 deletions.
  1. +8 −7 sources/htc_init.js
View
@@ -1,16 +1,17 @@
-var p = window['PIE'],
- el = element;
+var el = element;
function init() {
- if( p && doc.media !== 'print' ) { // IE strangely attaches a second copy of the behavior to elements when printing
- p['attach']( el );
+ var PIE = window[ 'PIE' ];
+ if( PIE && doc.media !== 'print' ) { // IE strangely attaches a second copy of the behavior to elements when printing
+ PIE['attach']( el );
}
}
function cleanup() {
- if (p) {
- p['detach']( el );
- p = el = 0;
+ var PIE = window[ 'PIE' ];
+ if (PIE) {
+ PIE['detach']( el );
+ PIE = el = 0;
}
}

0 comments on commit c5ecdd7

Please sign in to comment.