Opened 11 years ago
Closed 10 years ago
#10618 closed enhancement (fixed)
[patch][cla] dojox.storage: New providers
Reported by: | Jens Arps | Owned by: | Jens Arps |
---|---|---|---|
Priority: | high | Milestone: | 1.6 |
Component: | Storage/Flash | Version: | 1.4.0 |
Keywords: | storage | Cc: | |
Blocked By: | Blocking: |
Description
This patch adds the following providers for dojox.storage:
- localStorage
- MS IE userData behavior
- Cookies
With these providers, there's an almost 100% coverage of browsers supported by dojox.storage without having to rely on third party plugins such as Flash or Gears.
- localStorage addresses Firefox 3+, IE 8, Safari 4 (and the future, I guess)
- userData behavior addresses IE 5+
- Cookie storage is there to provide a fallback
A broad and reliable support of persistant storage mechanisms seems pretty important. To have it now, you'd have to use third party solutions such as Lawnchair or persist.js. It would be great if we had it built in with dojo.
I also edited the readme file and added an overview table of browsers and supported storage providers.
A test page including these providers is available here: http://jensarps.de/tests/dojo_tests/dojo-release-1.4.0-src/dojox/storage/tests/test_storage.html
NOTE: I added a patch for just the loacalStorage provider in December 2009 (http://bugs.dojotoolkit.org/ticket/10476). To ease things, this patch includes that provider as well.
Attachments (6)
Change History (18)
Changed 11 years ago by
Attachment: | storage.diff added |
---|
comment:1 Changed 11 years ago by
Component: | Dojox → Storage/Flash |
---|---|
Owner: | changed from Adam Peller to Shane O'Sullivan |
comment:2 Changed 11 years ago by
Can we get this reviewed and/or committed... looks like an awesome set of improvements!
comment:4 Changed 11 years ago by
Hi... Any chance we could get action on this? This is really important I think... Otherwise, have to fallback to Flash or the like...Thanks!
comment:5 follow-up: 6 Changed 11 years ago by
I have some time free this weekend, I'll have a go at it.
comment:6 Changed 11 years ago by
Hi,
I've detected one bug in BehaviorStorageProvider?, the function clear doesn't really clear the namespace I think you forgot to save the modification in the storage, see patch_clear_BehaviorStorageProvider.diff
I also think that we can add a little modification to the BehaviorStorageProvider? if we connect it to document.onreadystatechange it can be initialized before the parsing by dojo.parser. It is usefull for api which need to load some data before any widget creation or rendering. see Patch_initialize_BehaviorStorageProvider.
I hope my contribution will help you.
Changed 11 years ago by
Attachment: | Patch_clear_BehaviorStorageProvider.diff added |
---|
Fix bug in clear function.
Changed 11 years ago by
Attachment: | Patch_initialize_BehaviorStorageProvider.diff added |
---|
we connect BehaviorStorageProvider? contructor to document.onreadystatechange so it is initialized before the parsing by dojo.parser
comment:7 Changed 11 years ago by
Hi,
I think there is a little problem on HTML5 based localStorage. the "isAvailable" function tests if the "localStorage" object is present. Browsers who handle localStorage works fine but old browsers like IE6, Chrome 3, Safari 3 crashes when the localStorage object is tested.
I suggest to surround the test by a try and if we catch an error to return false.
isAvailable: function(){ /*Boolean*/ try{ localStorage; } catch (e){ return false; } return true; },
comment:9 Changed 11 years ago by
I did some testing over the weekend, covering follwowing browsers:
OSX: Safari 5, latest WebKit, Chrome 5, latest Chromium, FF 3.6, latest Minefield
Win XP: Opera 10.6, IE 7 & 8
The Behavior provider is, of course, only tested in IE. I did not, however, test the providers on IE 6 and 9, and on mobile browsers. These are the changes/fixes I made to the providers:
- CookieProvider:
- fixed a bug where
clear()
would nuke all namespaces instead of just the specified one. get()
now returns the expectednull
instead ofundefined
if a key is not present.
- fixed a bug where
- BehaviorProvider:
- fixed the above reported bug where
clear()
didn't update the internal keymap. - the store is now attached to the head, removing the dependency from addOnLoad inside of the provider
- fixed the above reported bug where
- LocalStorageProvider:
- added a typeof check in
isAvailable
. put()
now returns the message of an exception, if one is raised.
- added a typeof check in
The following attachments are diffs against the 1.4.0. trunk.
Changed 11 years ago by
Attachment: | BehaviorStorageProvider.js.diff added |
---|
Changed 11 years ago by
Attachment: | CookieStorageProvider.js.diff added |
---|
Changed 11 years ago by
Attachment: | LocalStorageProvider.js.diff added |
---|
comment:10 Changed 11 years ago by
Milestone: | tbd → 1.6 |
---|
comment:11 Changed 10 years ago by
Owner: | changed from Shane O'Sullivan to Jens Arps |
---|---|
Status: | new → assigned |
comment:12 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Patch including the three new providers and changes to _common.js and README