Skip to content

Commit

Permalink
fixed; nested props named type edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Apr 20, 2011
1 parent 379a19e commit 00ac96a
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lib/mongoose/document.js
Expand Up @@ -451,14 +451,24 @@ Document.prototype.__defineGetter__('modified', function () {
*/

function compile (tree, proto, prefix) {
for (var i in tree)
define(i, ((tree[i].constructor == Object
&& Object.keys(tree[i]).length)
&& (!tree[i].type || tree[i].__nested)
? tree[i]
var keys = Object.keys(tree)
, i = keys.length
, limb
, key;

while (i--) {
key = keys[i];
limb = tree[key];

define(key
, ((limb.constructor == Object
&& Object.keys(limb).length)
&& (!limb.type || limb.type.type)
? limb
: null)
, proto
, prefix);
, proto
, prefix);
}
};

function define (prop, subprops, prototype, prefix) {
Expand Down

0 comments on commit 00ac96a

Please sign in to comment.