diff --git a/can-define.js b/can-define.js index fe3b5c3..0e1703c 100644 --- a/can-define.js +++ b/can-define.js @@ -46,12 +46,14 @@ if(process.env.NODE_ENV !== 'production') { if (definition.get) { Object.defineProperty(definition.get, "name", { value: "get "+canReflect.getName(obj) + "."+prop, - writable: true + writable: true, + configurable: true }); } if (definition.set) { Object.defineProperty(definition.set, "name", { - value: "set "+canReflect.getName(obj) + "."+prop + value: "set "+canReflect.getName(obj) + "."+prop, + configurable: true }); } return Object.defineProperty(obj, prop, definition); @@ -271,16 +273,19 @@ define.property = function(typePrototype, prop, definition, dataInitializers, co if (definition.get) { Object.defineProperty(definition.get, "name", { value: canReflect.getName(typePrototype) + "'s " + prop + " getter", + configurable: true }); } if (definition.set) { Object.defineProperty(definition.set, "name", { value: canReflect.getName(typePrototype) + "'s " + prop + " setter", + configurable: true }); } if(isValueResolver(definition)) { Object.defineProperty(definition.value, "name", { value: canReflect.getName(typePrototype) + "'s " + prop + " value", + configurable: true }); } } diff --git a/list/list.js b/list/list.js index b92c778..b63c8eb 100644 --- a/list/list.js +++ b/list/list.js @@ -341,6 +341,7 @@ var eventsProtoSymbols = ("getOwnPropertySymbols" in Object) ? eventsProtoSymbols.forEach(function(sym) { Object.defineProperty(DefineList.prototype, sym, { + configurable: true, enumerable:false, value: define.eventsProto[sym], writable: true @@ -705,9 +706,8 @@ var defineListProto = { var ret; if(this._computed && this._computed[key] && this._computed[key].compute) { ret = {}; - ret.valueDependencies = new Set([ - this._computed[key].compute - ]); + ret.valueDependencies = new Set(); + ret.valueDependencies.add(this._computed[key].compute); } return ret; }, diff --git a/map/map-test.js b/map/map-test.js index 21c5f72..c0c39e9 100644 --- a/map/map-test.js +++ b/map/map-test.js @@ -1439,6 +1439,28 @@ QUnit.test("expandos use default type (#383)", function(){ }); QUnit.test("do not enumerate anything other than key properties (#369)", function(){ + // Internet Explorer doesn't correctly skip properties that are non-enumerable + // on the current object, but enumerable on the prototype: + var ancestor = { prop: true }; + var F = function() {}; + F.prototype = ancestor; + var descendant = new F(); + Object.defineProperty(descendant, "prop", { + writable: true, + configurable: true, + enumerable: false, + value: true + }); + + var test = {}; + for (var k in descendant) { + test[k] = descendant[k]; + } + if (test.prop) { + return QUnit.ok(test.prop, "Browser doesn't correctly skip shadowed enumerable properties"); + } + + var Type = DefineMap.extend({ aProp: "string", aMethod: function(){} @@ -1447,7 +1469,7 @@ QUnit.test("do not enumerate anything other than key properties (#369)", functio var instance = new Type({aProp: "VALUE", anExpando: "VALUE"}); var props = {}; - for(var prop in instance) { + for (var prop in instance) { props[prop] = true; } QUnit.deepEqual(props,{ diff --git a/map/map.js b/map/map.js index da43756..417ac0f 100644 --- a/map/map.js +++ b/map/map.js @@ -251,9 +251,8 @@ var defineMapProto = { var ret; if(this._computed && this._computed[key] && this._computed[key].compute) { ret = {}; - ret.valueDependencies = new Set([ - this._computed[key].compute - ]); + ret.valueDependencies = new Set(); + ret.valueDependencies.add(this._computed[key].compute); } return ret; } @@ -290,6 +289,7 @@ var eventsProtoSymbols = ("getOwnPropertySymbols" in Object) ? eventsProtoSymbols.forEach(function(sym) { Object.defineProperty(DefineMap.prototype, sym, { + configurable: true, enumerable:false, value: define.eventsProto[sym], writable: true diff --git a/test/test-define-only.js b/test/test-define-only.js index 42967d3..415ea19 100644 --- a/test/test-define-only.js +++ b/test/test-define-only.js @@ -1216,10 +1216,10 @@ testHelpers.dev.devOnlyTest("Setting a value with only a get() generates a warni QUnit.equal(finishErrorCheck(), 1); }); -testHelpers.dev.devOnlyTest("warn on using a Constructor for small-t type definintions", function() { - QUnit.expect(2); +testHelpers.dev.devOnlyTest("warn on using a Constructor for small-t type definitions", function() { + QUnit.expect(1); - var message = 'can-define: the definition for VM{}.currency uses a constructor for "type". Did you mean "Type"?'; + var message = /can-define: the definition for [\w{}\.]+ uses a constructor for "type"\. Did you mean "Type"\?/; var finishErrorCheck = testHelpers.dev.willWarn(message); function Currency() { @@ -1241,27 +1241,12 @@ testHelpers.dev.devOnlyTest("warn on using a Constructor for small-t type defini QUnit.equal(finishErrorCheck(), 1); - message = 'can-define: the definition for VM2{}.currency uses a constructor for "type". Did you mean "Type"?'; - finishErrorCheck = testHelpers.dev.willWarn(message); - - function VM2() {} - - define(VM2.prototype, { - currency: { - type: Currency, // should be `Type: Currency` - default: function() { - return new Currency({}); - } - } - }); - - QUnit.equal(finishErrorCheck(), 1); }); testHelpers.dev.devOnlyTest("warn with constructor for Value instead of Default (#340)", function() { QUnit.expect(1); - var message = "can-define: Change the 'Value' definition for VM{}.currency to 'Default'."; + var message = /can-define: Change the 'Value' definition for [\w\.{}]+.currency to 'Default'./; var finishErrorCheck = testHelpers.dev.willWarn(message); function Currency() {