Permalink
Browse files

Ditch the top-level PIE var in the .htc file, since it is very unreli…

…able and was allowing the conditional to get entered twice on different behavior attachments, resulting in double .js downloads.
  • Loading branch information...
1 parent 576790b commit cac6afb10a0787890cb7b9a5ad8b9c70dceba442 Jason Johnston committed Nov 25, 2011
Showing with 10 additions and 5 deletions.
  1. +10 −5 sources/htc_script.js
View
@@ -1,17 +1,20 @@
var el = element,
doc = el.document,
- docMode = doc.documentMode || 0,
- PIE = window[ 'PIE' ];
+ docMode = doc.documentMode || 0;
-if (!PIE && docMode < 10) {
+// NOTE: do NOT try maintaining a long-lived variable referencing window.PIE here at the top
+// level because for some reason it isn't reliably set when it should be on subsequent attachments
+// of the behavior, resulting in double loads of the JS file.
+
+if ( !window[ 'PIE' ] && docMode < 10 ) {
(function() {
var queue = {},
baseUrls = $DefaultBaseUrls$,
protocol = doc.location.protocol,
baseUrl, tester, isIE6, i = 0;
// Create stub PIE object
- PIE = window[ 'PIE' ] = {
+ window[ 'PIE' ] = {
'attach': function( el ) {
queue[ el[ 'uniqueID' ] ] = el;
},
@@ -38,7 +41,9 @@ if (!PIE && docMode < 10) {
var script = doc.createElement( 'script' );
script.async = true;
script.onreadystatechange = function() {
- var rs = script.readyState, id;
+ var PIE = window[ 'PIE' ],
+ rs = script.readyState,
+ id;
if ( queue && ( rs === 'complete' || rs === 'loaded' ) ) {
if ( 'version' in PIE ) {
for( id in queue ) {

0 comments on commit cac6afb

Please sign in to comment.