[whatwg] Attribute for holding private data for scripting

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.

Received on Wednesday, 11 April 2007 11:19:07 UTC