Set default type attribute for button html elements
According to standard the default type for <button> elements is "submit". Depending on compatibility mode IE might use "button", instead. To work around the IE bug this patch forces the standard "submit", if nothing is specified explicitly. See remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx : ----- The default value of the type attribute depends on the current document compatibility mode. The default value is submit. In other compatibility modes the default value is button. ... Windows Internet Explorer 8 and later. The default value of the type attribute depends on the current document compatibility mode. In IE8 Standards mode, the default value is submit. In other compatibility modes and earlier versions of Windows Internet Explorer, the default value is button. ----- Change-Id: I3b97a8cac74bbfca63699dfcbf1cc5e9a2cef193
This commit is contained in:
parent
ed131b3213
commit
514bdd184d
2 changed files with 18 additions and 8 deletions
|
|
@ -234,6 +234,13 @@ class Html {
|
|||
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 ) ) . '>';
|
||||
}
|
||||
|
|
@ -301,7 +308,6 @@ class Html {
|
|||
'button' => array(
|
||||
'formaction' => 'GET',
|
||||
'formenctype' => 'application/x-www-form-urlencoded',
|
||||
'type' => 'submit',
|
||||
),
|
||||
'canvas' => array(
|
||||
'height' => '150',
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class HtmlTest extends MediaWikiTestCase {
|
|||
}
|
||||
|
||||
public function testExpandAttributesSkipsNullAndFalse() {
|
||||
|
||||
|
||||
### EMPTY ########
|
||||
$this->assertEmpty(
|
||||
Html::expandAttributes( array( 'foo' => null ) ),
|
||||
|
|
@ -442,7 +442,7 @@ class HtmlTest extends MediaWikiTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test out Html::element drops default value
|
||||
* Test out Html::element drops or enforces default value
|
||||
* @cover Html::dropDefaults
|
||||
* @dataProvider provideElementsWithAttributesHavingDefaultValues
|
||||
*/
|
||||
|
|
@ -461,15 +461,12 @@ class HtmlTest extends MediaWikiTestCase {
|
|||
'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' )
|
||||
|
|
@ -560,6 +557,13 @@ class HtmlTest extends MediaWikiTestCase {
|
|||
'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 ),
|
||||
|
|
|
|||
Loading…
Reference in a new issue