ResourceLoaderStartUpModule: Remove no-op "delete isCompatible"
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 20 Mar 2014 04:15:25 +0000 (05:15 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 20 Mar 2014 04:21:36 +0000 (05:21 +0100)
Due to the way this function being defined as a function or var
declaration instead of a function expression assigned to a property
it can't be deleted.

JavaScript doesn't throw an error when deletion is not permitted
though, the operator returns false instead.

> delete isCompatible;
  false

We already removed 'delete startUp' from mediawiki.js in favour
of startUp = undefined; (r107402, r74325).

Change-Id: I7aa02e3f4deb3a4f00177b70978bfcb83c80988a

includes/resourceloader/ResourceLoaderStartUpModule.php

index 64fafd7..3482bfa 100644 (file)
@@ -234,8 +234,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        // Startup function
                        $configuration = $this->getConfig( $context );
                        $registrations = self::getModuleRegistrations( $context );
-                       $registrations = str_replace( "\n", "\n\t", trim( $registrations ) ); // fix indentation
-                       $out .= "var startUp = function() {\n" .
+                       // Fix indentation
+                       $registrations = str_replace( "\n", "\n\t", trim( $registrations ) );
+                       $out .= "var startUp = function () {\n" .
                                "\tmw.config = new " . Xml::encodeJsCall( 'mw.Map', array( $wgLegacyJavaScriptGlobals ) ) . "\n" .
                                "\t$registrations\n" .
                                "\t" . Xml::encodeJsCall( 'mw.config.set', array( $configuration ) ) .
@@ -245,8 +246,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        $scriptTag = Html::linkedScript( self::getStartupModulesUrl( $context ) );
                        $out .= "if ( isCompatible() ) {\n" .
                                "\t" . Xml::encodeJsCall( 'document.write', array( $scriptTag ) ) .
-                               "}\n" .
-                               "delete isCompatible;";
+                               "}";
                }
 
                return $out;