Skip to content

Commit

Permalink
Merge pull request #168 from canjs/observable-built-ins
Browse files Browse the repository at this point in the history
making it possible to serialize observable built-ins
  • Loading branch information
phillipskevin authored Aug 27, 2019
2 parents c59a289 + 88c4f3d commit f6096d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions reflections/shape/shape-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,18 @@ QUnit.test("assignDeepList", function(assert) {
], "assigned right");
});

QUnit.test(".serialize works for observable built ins", function(assert) {
var obj = document.createElement("div");
obj[canSymbol.for("can.serialize")] = function() {
return "serialized value";
};

// mark object as observable
obj[canSymbol.for("can.onKeyValue")] = function() {};

assert.deepEqual(shapeReflections.serialize(obj), "serialized value");
});


/*QUnit.test("getAllEnumerableKeys", function(){
Expand Down
2 changes: 1 addition & 1 deletion reflections/shape/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function isSerializedHelper(obj){
if(hasUpdateSymbol(obj)) {
return false;
}
return typeReflections.isBuiltIn(obj) && !typeReflections.isPlainObject(obj) && !Array.isArray(obj);
return typeReflections.isBuiltIn(obj) && !typeReflections.isPlainObject(obj) && !Array.isArray(obj) && !typeReflections.isObservableLike(obj);
}

// IE11 doesn't support primitives
Expand Down

0 comments on commit f6096d6

Please sign in to comment.