unset( $attribs['maxlength'] );
}
+ // According to standard the default type for <button> elements is "submit".
+ // Depending on compatibility mode IE might use "button", instead.
+ // We enforce the standard "submit".
+ if ( $element == 'button' && !isset( $attribs['type'] ) ) {
+ $attribs['type'] = 'submit';
+ }
+
return "<$element" . self::expandAttributes(
self::dropDefaults( $element, $attribs ) ) . '>';
}
'button' => array(
'formaction' => 'GET',
'formenctype' => 'application/x-www-form-urlencoded',
- 'type' => 'submit',
),
'canvas' => array(
'height' => '150',
}
public function testExpandAttributesSkipsNullAndFalse() {
-
+
### EMPTY ########
$this->assertEmpty(
Html::expandAttributes( array( 'foo' => null ) ),
}
/**
- * Test out Html::element drops default value
+ * Test out Html::element drops or enforces default value
* @cover Html::dropDefaults
* @dataProvider provideElementsWithAttributesHavingDefaultValues
*/
'area', array( 'shape' => 'rect' )
);
- $cases[] = array( '<button></button>',
+ $cases[] = array( '<button type=submit></button>',
'button', array( 'formaction' => 'GET' )
);
- $cases[] = array( '<button></button>',
+ $cases[] = array( '<button type=submit></button>',
'button', array( 'formenctype' => 'application/x-www-form-urlencoded' )
);
- $cases[] = array( '<button></button>',
- 'button', array( 'type' => 'submit' )
- );
$cases[] = array( '<canvas></canvas>',
'canvas', array( 'height' => '150' )
'input', array( 'type' => 'range', 'value' => '' ),
);
+ # <button> specific handling
+ # see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
+ $cases[] = array( '<button type=submit></button>',
+ 'button', array( 'type' => 'submit' ),
+ 'According to standard the default type is "submit". Depending on compatibility mode IE might use "button", instead.',
+ );
+
# <select> specifc handling
$cases[] = array( '<select multiple></select>',
'select', array( 'size' => '4', 'multiple' => true ),