Fix silly <table class=''>
authorAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 7 Sep 2009 15:25:22 +0000 (15:25 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 7 Sep 2009 15:25:22 +0000 (15:25 +0000)
includes/HTMLForm.php
includes/Html.php

index d66f859..a3b7ca6 100644 (file)
@@ -313,7 +313,8 @@ class HTMLForm {
                        $classes[] = 'mw-htmlform-nolabel';
                $classes = implode( ' ', $classes );
 
-               $tableHtml = "<table class='$classes'><tbody>\n$tableHtml\n</tbody></table>\n";
+               $tableHtml = Html::rawElement( 'table', array( 'class' => $classes ),
+                       Html::rawElement( 'tbody', array(), "\n$tableHtml\n" ) ) . "\n";
 
                return $subsectionHtml . "\n" . $tableHtml;
        }
index 089e3f7..bece509 100644 (file)
@@ -232,19 +232,24 @@ class Html {
 
                $element = strtolower( $element );
 
-               # Simple checks using $attribDefaults
                foreach ( $attribs as $attrib => $value ) {
                        $lcattrib = strtolower( $attrib );
+                       $value = strval( $value );
 
+                       # Simple checks using $attribDefaults
                        if ( isset( $attribDefaults[$element][$lcattrib] ) &&
-                       $attribDefaults[$element][$lcattrib] === $value ) {
+                       $attribDefaults[$element][$lcattrib] == $value ) {
+                               unset( $attribs[$attrib] );
+                       }
+
+                       if ( $lcattrib == 'class' && $value == '' ) {
                                unset( $attribs[$attrib] );
                        }
                }
 
                # More subtle checks
                if ( $element === 'link' && isset( $attribs['type'] )
-               && $attribs['type'] === 'text/css' ) {
+               && strval( $attribs['type'] ) == 'text/css' ) {
                        unset( $attribs['type'] );
                }
                if ( $element === 'select' && isset( $attribs['size'] ) ) {
@@ -252,12 +257,12 @@ class Html {
                                || ( isset( $attribs['multiple'] ) && $attribs['multiple'] !== false )
                        ) {
                                # A multi-select
-                               if ( $attribs['size'] === '4' ) {
+                               if ( strval( $attribs['size'] ) == '4' ) {
                                        unset( $attribs['size'] );
                                }
                        } else {
                                # Single select
-                               if ( $attribs['size'] === '1' ) {
+                               if ( strval( $attribs['size'] ) == '1' ) {
                                        unset( $attribs['size'] );
                                }
                        }