r59963 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59962‎ | r59963 | r59964 >
Date:19:01, 11 December 2009
Author:simetrical
Status:ok
Tags:
Comment:
Fix bugs in r59360, r59361, r59363

* spellcheck is not a boolean attribute; it is an enumerated attribute
whose possible values are "true" and "false". If it were boolean, the
permitted constructs would be <input spellcheck>, <input
spellcheck="spellcheck">, and <input spellcheck="">, which would all
set it true, and it would only be set to false if omitted entirely.
(It would be boolean if HTML5 had invented it, but can't be for
historical reasons.)
* spellcheck is valid on any HTML element, not just input, and so should
be stripped on any element.

For reference, a table of all HTML5 attributes can be found at:

<http://www.whatwg.org/specs/web-apps/current-work/multipage/section-index.html#attributes-0&gt;
Modified paths:
  • /trunk/phase3/includes/Html.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Html.php
@@ -81,7 +81,6 @@
8282 'reversed',
8383 'scoped',
8484 'seamless',
85 - 'spellcheck',
8685 );
8786
8887 /**
@@ -113,13 +112,10 @@
114113 # consistency and better compression.
115114 $element = strtolower( $element );
116115
117 - # Element-specific hacks to slim down output and ensure validity
118 - if ( $element == 'input' ) {
119 - if ( !$wgHtml5 ) {
120 - # With $wgHtml5 off we want to validate as XHTML 1, so we
121 - # strip out any fancy HTML 5-only input types for now.
122 - #
123 - # Whitelist of valid types:
 116+ # Remove HTML5-only attributes if we aren't doing HTML5
 117+ if ( !$wgHtml5 ) {
 118+ if ( $element == 'input' ) {
 119+ # Whitelist of valid XHTML1 types
124120 $validTypes = array(
125121 'hidden',
126122 'text',
@@ -137,23 +133,23 @@
138134 # Fall back to type=text, the default
139135 unset( $attribs['type'] );
140136 }
141 - # Here we're blacklisting some HTML5-only attributes...
142 - $html5attribs = array(
143 - 'autocomplete',
144 - 'autofocus',
145 - 'max',
146 - 'min',
147 - 'multiple',
148 - 'pattern',
149 - 'placeholder',
150 - 'required',
151 - 'step',
152 - 'spellcheck',
153 - );
154 - foreach ( $html5attribs as $badAttr ) {
155 - unset( $attribs[$badAttr] );
156 - }
157137 }
 138+ # Here we're blacklisting some HTML5-only attributes...
 139+ $html5attribs = array(
 140+ 'autocomplete',
 141+ 'autofocus',
 142+ 'max',
 143+ 'min',
 144+ 'multiple',
 145+ 'pattern',
 146+ 'placeholder',
 147+ 'required',
 148+ 'step',
 149+ 'spellcheck',
 150+ );
 151+ foreach ( $html5attribs as $badAttr ) {
 152+ unset( $attribs[$badAttr] );
 153+ }
158154 }
159155
160156 $start = "<$element" . self::expandAttributes(

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59360bug 21604 Spellcheck attribute for editsummaryreedy18:38, 23 November 2009
r59361Minor followup for r59360...reedy18:52, 23 November 2009
r59363Further followup to r59360...reedy19:16, 23 November 2009

Status & tagging log