diff --git a/map/map-test.js b/map/map-test.js index 60dcddd..e7aa093 100644 --- a/map/map-test.js +++ b/map/map-test.js @@ -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"); +}); diff --git a/map/map.js b/map/map.js index df17bc0..3e0bf3f 100644 --- a/map/map.js +++ b/map/map.js @@ -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