No increasing number value in session and persistent storage

RESOLVED INVALID

Status

()

RESOLVED INVALID
12 years ago
12 years ago

People

(Reporter: channy, Unassigned)

Tracking

Trunk
mozilla1.8.1beta1
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

12 years ago
There is very simple sample code in http://www.whatwg.org/specs/web-apps/current-work/#introduction2. But it doesn't work a sample code of increasing page count in Bon Echo alpha 3. You can see this bug in http://channy.creation.net/work/firefox/domstorage/ too.
(Reporter)

Updated

12 years ago
Blocks: 335540

Comment 1

12 years ago
I checked the code in the sample and found the sample code is somewhat misleading. Here is the problemtic code.

  if (!storage.pageLoadCount)
    storage.pageLoadCount = 0;
  storage.pageLoadCount += 1;
  document.getElementById('count').textContent = storage.pageLoadCount;

In the spec, storage item has string (DOMString) value. Thus, 0 is converted into "0" when saved into storage. And "0" + 1 in the next statement results "01" following javascript datat type conversion.

In short, the problem does not lie in the implementataion but in the sample code. It should be modified like below.

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

Comment 2

12 years ago
I had chat with Channy and learned that he notified this to WHATWG list. 

http://listserver.dreamhost.com/pipermail/whatwg-whatwg.org/2006-June/006515.html
(Reporter)

Comment 3

12 years ago
Thanks. I followed up this to WHATWG mailing list to correct sample code.
But, I'm not sure to clode this bug. After a feedback from WHATWG, I'll decide it.
Spec has been fixed. Thanks for reporting it!
I believe Mozilla works per spec here (now that the spec has been fixed). Marking INVALID.
Status: NEW → RESOLVED
Last Resolved: 12 years ago
OS: Windows 2000 → All
Hardware: PC → All
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.