Page MenuHomePhabricator

Support HTML5 data-* attributes
Closed, ResolvedPublic

Description

HTML5 has a handy new feature. data-* attributes.
Lowercase attributes starting with data- are reserved by HTML5 for sites to store custom data in for use by their scripts (not for external use, and browsers are prohibited from giving them any special meaning).

HTML5 does define an elm.dataset used for getting data from those data- attributes, but that's not necessary to rely on as data- attributes can be extracted the same way as

For a long period of time we've rejected html attributes from elements (except for a select few) to avoid people placing on* attributes, or other special attributes which may be interpreted by the browser in a way that could harm the reader.

As a result scripts like show/hide, and piles of others have resorted to abusing the class tag to pass config data to scripts.

HTML5 now defines data- as something which is safe to use. I think we should tweak the parser to allow data- attributes to be used inside markup, this way instead of abusing css classes scripts can make use of data- attributes to control their behavior.


Version: unspecified
Severity: enhancement
URL: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#embedding-custom-non-visible-data

Details

Reference
bz20495

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:52 PM
bzimport set Reference to bz20495.
bzimport added a subscriber: Unknown Object (MLST).

theevilipaddress wrote:

This was added some time ago already and is available if $wgHtml5 is true, so marking as FIXED.

ayg wrote:

Specifically, this was added in r70980.