Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ie11 configurable #386

Merged
merged 9 commits into from
Sep 17, 2018
9 changes: 7 additions & 2 deletions can-define.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
},
Expand Down
24 changes: 23 additions & 1 deletion map/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){}
Expand All @@ -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,{
Expand Down
6 changes: 3 additions & 3 deletions map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,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;
}
Expand Down Expand Up @@ -277,6 +276,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
Expand Down
23 changes: 4 additions & 19 deletions test/test-define-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down