fix Ox.localStorage for Firefox 3.6

This commit is contained in:
rolux 2012-07-05 19:48:20 +02:00
parent b8f88958da
commit a155ff5487

View file

@ -91,8 +91,12 @@ Ox.localStorage <f> localStorage wrapper
{}
@*/
Ox.localStorage = function(namespace) {
if (!window.localStorage) {
window.localStorage = {};
var localStorage = window.localStorage || {};
// FF 3.6 can't assign to or iterate over localStorage
try {
window.localStorage = localStorage;
} catch (e) {
localStorage = {};
}
function storage(key, value) {
var ret;
@ -260,12 +264,12 @@ Ox.wrap <f> Wraps a value so that one can directly call any Ox function on it
chain <f> Wrap return values to allow chaining
value <f> Unwrap the value wrapped by `chain()`
value <*> Any value
> Ox("foobar").repeat(2)
"foobarfoobar"
> Ox("foobar").chain().reverse().toTitleCase().value()
"Raboof"
> Ox.wrap("foobar").value()
"foobar"
> Ox('foobar').repeat(2)
'foobarfoobar'
> Ox('foobar').chain().reverse().toTitleCase().value()
'Raboof'
> Ox.wrap('foobar').value()
'foobar'
@*/
Ox.wrap = function(value, chained) {
// somewhat inspired by underscore.js