Html::expandAttributes( array( 'foo' => null ) ); ' foo=""' -> ''
authorDaniel Friesen <dantman@users.mediawiki.org>
Sat, 5 Feb 2011 20:28:04 +0000 (20:28 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Sat, 5 Feb 2011 20:28:04 +0000 (20:28 +0000)
Outputting ' foo="" on `foo = null` promotes the writing of overly verbose code to avoid it, and ugly methods like our old Linker::getLinkAttributesInternal, both of which are completely counter to the purpose of Html::.

includes/Html.php

index 2e34660..4e6e611 100644 (file)
@@ -352,7 +352,7 @@ class Html {
                $ret = '';
                $attribs = (array)$attribs;
                foreach ( $attribs as $key => $value ) {
-                       if ( $value === false ) {
+                       if ( $value === false || is_null( $value ) ) {
                                continue;
                        }