[whatwg] Wrong sample code in 4.9.1 of Web Application 1.0 spec

Channy Yun channy at gmail.com
Fri Jun 2 10:48:04 PDT 2006


Dear WHATWG,

As you know, Bon Echo Alpha3 starts to support client-side session and
persistent storage in Web Application 1.0 spec made by WHATWG. But, as
following sample code of 4.9.1 doesn't work in Bon Echo Alpha 3.

<p>
  You have viewed this page
  <span id="count">an untold number of</span>
  time(s).
</p>
<script>
  var storage = globalStorage['example.com'];
  if (!storage.pageLoadCount)
    storage.pageLoadCount = 0;
  storage.pageLoadCount += 1;
  document.getElementById('count').textContent = storage.pageLoadCount;
</script>

Only one line must be fixed.

->storage.pageLoadCount += 1;
+>storage.pageLoadCount = parseInt(storage.pageLoadCount) + 1;

It alway retruns string so it must be parsed to number.
I am not sure whether there is bug from spec or firefox.

https://bugzilla.mozilla.org/show_bug.cgi?id=340072
http://channy.creation.net/work/firefox/domstorage/

Channy

-----------------------------------------------------------------
Seokchan Yun, Mozilla Korean Community
http://www.creation.net



More information about the whatwg mailing list