title: Javascript DOM: Setting custom DOM element properties
body: <p>Is it ok to set custom properties on DOM elements, and rely on them persisting?</p>
  
  <p>For example, given </p>
  
  <pre><code> &lt;html&gt;&lt;body&gt;&lt;div id="foo"&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Would it be fair to do <code>document.getElementById('foo').bar = "baz";</code>, and expect <code>document.getElementsByTagName('div')[0].bar</code> to equal <code>"baz"</code>?</p>
  
  <p>Note that I'm talking about properties as in normal javascript object properties here, not element attributes.</p>
  
  <p>I'm interested both in how cross-browser it is, and whether its supported in any spec.</p>
  
  <p>Does the DOM API guarantee that the same javascript object will be returned for the same DOM element every time?</p>