diff --git a/can-define.js b/can-define.js index 470c120..60a53f6 100644 --- a/can-define.js +++ b/can-define.js @@ -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; } @@ -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 }); }; diff --git a/define-test.js b/define-test.js index 872ef37..aafb685 100644 --- a/define-test.js +++ b/define-test.js @@ -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"); +}); diff --git a/list/list-test.js b/list/list-test.js index 0db8bf6..913ff37 100644 --- a/list/list-test.js +++ b/list/list-test.js @@ -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.'); + } }); diff --git a/package.json b/package.json index 81f9960..4fda1db 100644 --- a/package.json +++ b/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": {