Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -685,23 +685,30 @@ |
686 | 686 | script.setAttribute( 'src', src ); |
687 | 687 | script.setAttribute( 'type', 'text/javascript' ); |
688 | 688 | if ( $.isFunction( callback ) ) { |
689 | | - // Attach handlers for all browsers -- this is based on jQuery.getScript |
| 689 | + // Attach handlers for all browsers -- this is based on jQuery.ajax |
690 | 690 | script.onload = script.onreadystatechange = function() { |
| 691 | + |
691 | 692 | if ( |
692 | 693 | !done |
693 | 694 | && ( |
694 | | - !this.readyState |
695 | | - || this.readyState === 'loaded' |
696 | | - || this.readyState === 'complete' |
| 695 | + !script.readyState |
| 696 | + || /loaded|complete/.test( script.readyState ) |
697 | 697 | ) |
698 | 698 | ) { |
| 699 | + |
699 | 700 | done = true; |
700 | | - callback(); |
| 701 | + |
701 | 702 | // Handle memory leak in IE |
702 | 703 | script.onload = script.onreadystatechange = null; |
| 704 | + |
| 705 | + callback(); |
| 706 | + |
703 | 707 | if ( script.parentNode ) { |
704 | 708 | script.parentNode.removeChild( script ); |
705 | 709 | } |
| 710 | + |
| 711 | + // Dereference the script |
| 712 | + script = undefined; |
706 | 713 | } |
707 | 714 | }; |
708 | 715 | } |