Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -933,7 +933,26 @@ |
934 | 934 | script.setAttribute( 'src', src ); |
935 | 935 | script.setAttribute( 'type', 'text/javascript' ); |
936 | 936 | if ( $.isFunction( callback ) ) { |
937 | | - script.onload = script.onreadystatechange = callback; |
| 937 | + var done = false; |
| 938 | + // Attach handlers for all browsers -- this is based on jQuery.getScript |
| 939 | + script.onload = script.onreadystatechange = function() { |
| 940 | + if ( |
| 941 | + !done |
| 942 | + && ( |
| 943 | + !this.readyState |
| 944 | + || this.readyState === "loaded" |
| 945 | + || this.readyState === "complete" |
| 946 | + ) |
| 947 | + ) { |
| 948 | + done = true; |
| 949 | + callback(); |
| 950 | + // Handle memory leak in IE |
| 951 | + script.onload = script.onreadystatechange = null; |
| 952 | + if ( script.parentNode ) { |
| 953 | + script.parentNode.removeChild( script ); |
| 954 | + } |
| 955 | + } |
| 956 | + }; |
938 | 957 | } |
939 | 958 | document.body.appendChild( script ); |
940 | 959 | } else { |