W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2007

[whatwg] Attribute for holding private data for scripting

From: Kevin Marks <kevinmarks@gmail.com>
Date: Wed, 11 Apr 2007 11:19:07 -0700
Message-ID: <73766b160704111119o6249055fl64ffb3a4b29b88d@mail.gmail.com>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:54 UTC