[Ur] Data attributes
Patrick Hurst
phurst at mit.edu
Thu Feb 20 17:56:14 EST 2014
Any attribute whose name starts with 'data-' is valid on any HTML5
element with any value (see
<http://www.w3.org/html/wg/drafts/html/CR/dom.html> section 3.5.9). Some
frameworks, such as Twitter Bootstrap 3, rely on the presence of these,
but right now there's no easy built-in way to include them using Ur/Web
XML literals.
One approach would be to add a 'data' pseudotag, similar to the 'link'
tag on <a> elements, whose value is a record all of whose values are
strings; [<div data={{Foo = "bar"}}/>] would then be rendered as [<div
data-foo="bar"></div>]. The downside of this is that it'd involve
significant changes to the standard library type system, since the [tag]
type constructor would then need a new field for the names of all the
data- attributes.
Another approach is to have the value of the 'data' tag be a list of
tuples of strings; [<div data={("foo", "bar") :: nil}/>] would then be
rendered as [<div data-foo="bar"></div>]. I think this would be less
safe, but also significantly easier to implement.
I e-mailed Adam about this and he suggested I take it to the list. What
do you all think?
More information about the Ur
mailing list