diff --git a/README.md b/README.md index f0786d1..a9f35f9 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,8 @@ OBJECT TREE |-- [var] testObject['testSpecial-Name!'] > (null) |-- [fun] testClass() |-- testClass.prototype - |-- [fun] testClass.prototype['a']() - |-- [fun] testClass.prototype['b']() + |-- [fun] testClass.prototype.a() + |-- [fun] testClass.prototype.b() |-- [var] testClass.CONSTANT > true |-- [var] testClass.data > 10 |-- [fun] testFunction(a, b, c) diff --git a/objtree.js b/objtree.js index 0144e3a..7cfc908 100644 --- a/objtree.js +++ b/objtree.js @@ -131,7 +131,7 @@ return v === 0 ? +(entry1[0] > entry2[0]) : v; }; - var keyRegex = /^[a-z_$][a-z0-9_$]+$/i; + var keyRegex = /^[a-z_$][a-z0-9_$]*$/i; var getKeyAccess = function(key){ return keyRegex.test(key) ? "."+key : "['"+key+"']";