HTML5 allows any attribute beginning with "data-" to be used for
site-specific purposes:
http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#embedding-custom-non-visible-data
I don't see any reason not to allow this. It means users won't have to
hackily overload title="" or class="" if they want to store per-element
data for scripts.
* (bug 11005) Add CSS class to empty pages in Special:Newpages
* The parser cache is now shared amongst users whose different settings aren't
used in the page.
* (bug 11005) Add CSS class to empty pages in Special:Newpages
* The parser cache is now shared amongst users whose different settings aren't
used in the page.
+* Any attribute beginning with "data-" can now be used in wikitext, per HTML5.
=== Bug fixes in 1.17 ===
* (bug 17560) Half-broken deletion moved image files to deletion archive
=== Bug fixes in 1.17 ===
* (bug 17560) Half-broken deletion moved image files to deletion archive
* @todo Check for unique id attribute :P
*/
static function validateAttributes( $attribs, $whitelist ) {
* @todo Check for unique id attribute :P
*/
static function validateAttributes( $attribs, $whitelist ) {
- global $wgAllowRdfaAttributes, $wgAllowMicrodataAttributes;
+ global $wgAllowRdfaAttributes, $wgAllowMicrodataAttributes, $wgHtml5;
$whitelist = array_flip( $whitelist );
$hrefExp = '/^(' . wfUrlProtocols() . ')[^\s]+$/';
$whitelist = array_flip( $whitelist );
$hrefExp = '/^(' . wfUrlProtocols() . ')[^\s]+$/';
- if( !isset( $whitelist[$attribute] ) ) {
+ # Allow any attribute beginning with "data-", if in HTML5 mode
+ if ( !($wgHtml5 && preg_match( '/^data-/i', $attribute )) && !isset( $whitelist[$attribute] ) ) {
+!! test
+HTML5 data attributes
+!! input
+<span data-foo="bar">Baz</span>
+<p data-abc-def_hij="">Quuz</p>
+!! result
+<p><span data-foo="bar">Baz</span>
+</p>
+<p data-abc-def_hij="">Quuz</p>
+
+!! end
+