Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dont-redefine-data
Browse files Browse the repository at this point in the history
  • Loading branch information
bmomberger-bitovi committed May 2, 2017
2 parents e3c3858 + 6c70983 commit 18531dd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
6 changes: 4 additions & 2 deletions can-define.js
Expand Up @@ -160,7 +160,8 @@ define.property = function(objPrototype, prop, definition, dataInitializers, com
Object.defineProperty(objPrototype, prop, {
get: make.get.data(prop),
set: make.set.events(prop, make.get.data(prop), make.set.data(prop), make.eventType.data(prop)),
enumerable: true
enumerable: true,
configurable: true
});
return;
}
Expand Down Expand Up @@ -243,7 +244,8 @@ define.property = function(objPrototype, prop, definition, dataInitializers, com
Object.defineProperty(objPrototype, prop, {
get: getter,
set: setter,
enumerable: "serialize" in definition ? !!definition.serialize : !definition.get
enumerable: "serialize" in definition ? !!definition.serialize : !definition.get,
configurable: true
});
};

Expand Down
25 changes: 25 additions & 0 deletions define-test.js
Expand Up @@ -1504,3 +1504,28 @@ QUnit.test('setter with default value causes an infinite loop (#142)', function(
var a = new A();
QUnit.equal(a.val, 'hello', 'creating an instance should not cause an inifinte loop');
});

QUnit.test('defined properties are configurable', function(){
var A = define.Constructor({
val: {
get: function(){
return "foo";
}
}
});

var dataInitializers = A.prototype._define.dataInitializers,
computedInitializers = A.prototype._define.computedInitializers;

var newDefinition = {
get: function(){
return "bar";
}
};

define.property(A.prototype, "val", newDefinition, dataInitializers,
computedInitializers);

var a = new A();
QUnit.equal(a.val, "bar", "It was redefined");
});
12 changes: 5 additions & 7 deletions list/list-test.js
Expand Up @@ -371,14 +371,12 @@ test('list.map', function() {
person.lastName = "Thompson";
return person;
});
QUnit.throws(function() {

try {
newExtendedList.testMe();
}, {
name: 'TypeError',
message: (navigator.userAgent.indexOf("Trident") > -1 ?
"Object doesn't support property or method 'testMe'" :
"newExtendedList.testMe is not a function")
}, 'Does not return the same type of list.');
} catch(err) {
QUnit.ok(err.message.match(/testMe/), 'Does not return the same type of list.');
}
});


Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "can-define",
"version": "1.0.21",
"version": "1.0.24",
"description": "Create observable objects with JS dot operator compatibility",
"main": "can-define.js",
"scripts": {
Expand Down

0 comments on commit 18531dd

Please sign in to comment.