Skip to content

Commit

Permalink
Use prototype properties as defaults
Browse files Browse the repository at this point in the history
Closes #91
  • Loading branch information
m-mujica committed Feb 28, 2018
1 parent ace5d1e commit 4182fae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions can-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ var Map = Construct.extend(
if (
prop !== "define" &&
prop !== "constructor" &&
(
typeof this.prototype[prop] !== "function" && !canReflect.isValueLike(this.prototype[prop]) ||
this.prototype[prop].prototype instanceof Construct
)
(typeof this.prototype[prop] !== "function" ||
this.prototype[prop].prototype instanceof Construct)
) {
this.defaults[prop] = this.prototype[prop];
} else if (canReflect.isObservableLike(this.prototype[prop])) {
Expand Down
6 changes: 6 additions & 0 deletions can-map_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,9 @@ QUnit.test("can.isBound", function(){
var p = new Person();
QUnit.ok(! p[canSymbol.for("can.isBound")](), "not bound");
});

QUnit.test("prototype properties", function(assert) {
var MyMap = Map.extend({ letters: "ABC" });
var map = new MyMap();
assert.equal(map.attr("letters"), "ABC");
});

0 comments on commit 4182fae

Please sign in to comment.