[whatwg] Attribute for holding private data for scripting
Kevin Marks
kevinmarks at gmail.com
Wed Apr 11 11:19:07 PDT 2007
On 4/11/07, Jon Barnett <jonbarnett at gmail.com> wrote:
> > If you want structured data in this attribute, why not just use JSON?
>
> That's an idea that crossed my mind as well. I dismissed it for a few
> reasons:
> - authors would have to entitize quotes and ampersands in their attributes,
> which they're not used to doing with JSON normally.
> - evaluating it would mean:
> var obj = eval(myelement.getAttribute("_myjson");
How about defining an attribute that is the name of the js variable
for use with that element? Then you can define the variable in a
<script> tag, and use pure JSON cleanly.
Kristof, JSON is in fact pretty much valid Python syntax too. It is a
Javascript subset for decalarative structures designed to interoperate
with many languages.
More information about the whatwg
mailing list