Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #174 (DefineMap.keys should return serialize: true properties) #179

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions map/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,26 @@ QUnit.test(".value functions should not be observable", function(){

equal(count, 1);
});

QUnit.test("DefineMap.keys returns serialize: true properties (#174)", function () {
var Foo = DefineMap.extend({
first: "string",
last: "string",
fullName: {
get: function () {
return this.first + this.last;
},
serialize: true
},
greeting: {
get: function () {
return "hello " + this.fullName();
}
}
});
var foo = new Foo();

var keys = DefineMap.keys(foo);

QUnit.equal(keys[0], "fullName", "DefineMap.keys returns only serialize: true properties");
});
10 changes: 10 additions & 0 deletions map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ var DefineMap = Construct.extend("DefineMap",{
}
}
define.defineConfigurableAndNotEnumerable(prototype, "constructor", this);
},

keys: function (map) {
var keys = [], definitions = map._define.definitions;
for (var keyName in definitions) {
if (definitions[keyName].serialize) {
keys.push(keyName);
}
}
return keys;
}
},{
// setup for only dynamic DefineMap instances
Expand Down