Skip to content

Commit

Permalink
Work around a hilariously bad enumeration bug
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaswilburn committed Sep 5, 2018
1 parent ed22618 commit 292f368
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions map/map-test.js
Expand Up @@ -1439,6 +1439,27 @@ 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];
console.log(test);
debugger;
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 @@ -1448,6 +1469,8 @@ QUnit.test("do not enumerate anything other than key properties (#369)", functio

var props = {};
for(var prop in instance) {
var descriptor = Object.getOwnPropertyDescriptor(instance, prop);
if (!descriptor) descriptor = Object.getOwnPropertyDescriptor(Type.prototype, prop) || {};
props[prop] = true;
}
QUnit.deepEqual(props,{
Expand Down
2 changes: 1 addition & 1 deletion test/test-define-only.js
Expand Up @@ -1246,7 +1246,7 @@ testHelpers.dev.devOnlyTest("warn on using a Constructor for small-t type defini
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

0 comments on commit 292f368

Please sign in to comment.