From 9d3af3cf719c3969b042fffb5667c7b8e0f0c185 Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Fri, 21 Apr 2017 20:51:52 +0530 Subject: [PATCH 1/3] Fix #174 (DefineMap.keys should return serialize: true properties) Add "keys" function to static properties of DefineMap. Make it iterate over all define definitions and return only those properties which have serialize set to true --- map/map-test.js | 23 +++++++++++++++++++++++ map/map.js | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/map/map-test.js b/map/map-test.js index 60dcddd..e4e0e9d 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"); +}); \ No newline at end of file diff --git a/map/map.js b/map/map.js index df17bc0..f6cbde3 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 From c21b39d1bfe86d2165c532c204730a21442a1da0 Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Fri, 21 Apr 2017 21:15:46 +0530 Subject: [PATCH 2/3] Fix #174 (DefineMap.keys should return serialize: true properties) Add "keys" function to static properties of DefineMap. Make it iterate over all define definitions and return only those properties which have serialize set to true --- map/map-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map/map-test.js b/map/map-test.js index e4e0e9d..e7aa093 100644 --- a/map/map-test.js +++ b/map/map-test.js @@ -671,4 +671,4 @@ QUnit.test("DefineMap.keys returns serialize: true properties (#174)", function var keys = DefineMap.keys(foo); QUnit.equal(keys[0], "fullName", "DefineMap.keys returns only serialize: true properties"); -}); \ No newline at end of file +}); From 073da029377681abe31d961850640f9a5892e457 Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Fri, 21 Apr 2017 21:22:04 +0530 Subject: [PATCH 3/3] Fix #174 (DefineMap.keys should return serialize: true properties) Add "keys" function to static properties of DefineMap. Make it iterate over all define definitions and return only those properties which have serialize set to true --- map/map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map/map.js b/map/map.js index f6cbde3..3e0bf3f 100644 --- a/map/map.js +++ b/map/map.js @@ -110,7 +110,7 @@ var DefineMap = Construct.extend("DefineMap",{ keys: function (map) { var keys = [], definitions = map._define.definitions; for (var keyName in definitions) { - if (definitions[keyName]['serialize']) { + if (definitions[keyName].serialize) { keys.push(keyName); } }