W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2006

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

From: Channy Yun <channy@gmail.com>
Date: Sat, 3 Jun 2006 02:48:04 +0900
Message-ID: <3586624e0606021048q2e6fcaf4ge59e3d8d638924c2@mail.gmail.com>
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
Received on Friday, 2 June 2006 10:48:04 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:27 UTC