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

[whatwg] Attribute for holding private data for scripting

From: Kristof Zelechovski <giecrilj@stegny.2a.pl>
Date: Wed, 11 Apr 2007 18:41:52 +0200
Message-ID: <000301c77c58$4f59a5f0$1a01080a@POCZTOWIEC>
The exact syntax for the attribute should depend on the script type.  

It can be PythON for Python (I do not know Python at all but I assume it is
possible) and LispON for Lisp.

(as client side Lisp is my personal dream)

Chris

 

  _____  

From: whatwg-bounces@lists.whatwg.org
[mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Jon Barnett
Sent: Wednesday, April 11, 2007 2:39 PM
To: Anne van Kesteren
Cc: WHAT working group; ddailey; Maciej Stachowiak; Simon Pieters; Henri
Sivonen; Sam Ruby
Subject: Re: [whatwg] Attribute for holding private data for scripting

 

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"); 
which I don't like because I prefer to avoid eval at all costs.
- it further marries HTML with JavaScript, which is something I'd like to
see evolve and change in the future - something else widely supported, like
client-side Python is a personal dream.  Also, whatever attribute also needs
to have meaning (read: be easy to get to in the DOM) when your document is
processed by something other than a browser, such as PHP or Java. 

You, yourself, could still format your custom data that way, but I don't
think it's a great idea to spec it that way.  And I guess it's already been
said that changing something in the DOM a good idea for this.  

We just want to allow authors to continue to do something authors already do
without making validators complain.

The idea of allowing just any attribute that starts with _  (or x_) has the
best benefit - authors already do it, it's just a matter of making
validators not complain. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20070411/2c9fdffb/attachment.htm>
Received on Wednesday, 11 April 2007 09:41:52 UTC

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