r93013 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93012‎ | r93013 | r93014 >
Date:20:38, 24 July 2011
Author:krinkle
Status:ok
Tags:
Comment:
More mediawiki.js cleanup (addScript AJAX)
- Update and merge in jQuery fixes:
-- Dereference script (added)
-- Order of actions
-- Regex instead of two string comparisons
-- Unit tests still pass :)

Follows up: r92933, 93012
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -685,23 +685,30 @@
686686 script.setAttribute( 'src', src );
687687 script.setAttribute( 'type', 'text/javascript' );
688688 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
690690 script.onload = script.onreadystatechange = function() {
 691+
691692 if (
692693 !done
693694 && (
694 - !this.readyState
695 - || this.readyState === 'loaded'
696 - || this.readyState === 'complete'
 695+ !script.readyState
 696+ || /loaded|complete/.test( script.readyState )
697697 )
698698 ) {
 699+
699700 done = true;
700 - callback();
 701+
701702 // Handle memory leak in IE
702703 script.onload = script.onreadystatechange = null;
 704+
 705+ callback();
 706+
703707 if ( script.parentNode ) {
704708 script.parentNode.removeChild( script );
705709 }
 710+
 711+ // Dereference the script
 712+ script = undefined;
706713 }
707714 };
708715 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92933Minor mw.loader fixes...krinkle09:09, 23 July 2011

Status & tagging log