Skip to content

Commit

Permalink
Merge pull request #3 from bfontaine/undefined-keys
Browse files Browse the repository at this point in the history
Fix for undefined keys & values
  • Loading branch information
nikopol committed Jun 5, 2014
2 parents 8f388f3 + b80250d commit 9caf8dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions minitools.js
Expand Up @@ -44,7 +44,7 @@ var
hash=(function(){
"use strict";
var h, p,
hash=function(){ return document.location.href.replace(/^.*?#/,'') },
hash=function(){ return document.location.hash.slice(1) },
encode=function(s){ return s.replace(/&/g,'%26').replace(/=/g,'%3D') },
decode=function(s){ return decodeURIComponent(s) },
serialize=function(){
Expand All @@ -66,9 +66,9 @@ hash=(function(){
};
unserialize();
return {
del: function(key){ if(h[key]!=undefined){ delete h[key]; return serialize(h) } return false },
del: function(key){ if(h.hasOwnProperty(key)){ delete h[key]; return serialize(h) } return false },
set: function(key,val){ return serialize(typeof(key)=='object' ? h = key : h[key] = val) },
get: function(key){ return key==undefined ? h : h[key]||'' },
get: function(key){ return arguments.length ? h[key]||'' : h },
link: function(o){
var z=[];
if(o) for(var k in o) z.push(k+'='+encode(o[k]));
Expand Down Expand Up @@ -167,4 +167,4 @@ htmlencode=function(s) {
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
};
};

0 comments on commit 9caf8dd

Please sign in to comment.