IE11 Nodelist iterator - out of stack space error
JakeChampion opened this issue · comments
When attaching the Symbol.iterator property onto a NodeList there seems to be a function called which is stuck in a recursive loop. This error only seems to happen on IE11.
JSBin page to demonstrate the error -- http://jsbin.com/bujuhuseso/1/edit?html,js,console,output
When I change it to use the .max
build file, it points me to https://github.com/es-shims/get-own-property-symbols/blob/master/build/get-own-property-symbols.max.js#L104 - I'm not sure how to debug from there.
I believe it can be resolved by changing this:
https://github.com/es-shims/get-own-property-symbols/blob/master/build/get-own-property-symbols.max.js#L222-L241
try { // fails in few pre ES 5.1 engines
setDescriptor = create(
defineProperty(
{},
prefix,
{
get: function () {
return defineProperty(this, prefix, {value: false})[prefix];
}
}
)
)[prefix] || defineProperty;
} catch(o_O) {
setDescriptor = function (o, key, descriptor) {
var protoDescriptor = gOPD(ObjectProto, key);
delete ObjectProto[key];
defineProperty(o, key, descriptor);
defineProperty(ObjectProto, key, protoDescriptor);
};
}
try { // fails in few pre ES 5.1 engines
setDescriptor = create(
defineProperty(
{},
prefix,
{
get: function () {
return defineProperty(this, prefix, {value: false})[prefix];
}
}
)
)[prefix] || function (o, key, descriptor) {
var protoDescriptor = gOPD(ObjectProto, key);
delete ObjectProto[key];
defineProperty(o, key, descriptor);
defineProperty(ObjectProto, key, protoDescriptor);
};
} catch(o_O) {
setDescriptor = function (o, key, descriptor) {
var protoDescriptor = gOPD(ObjectProto, key);
delete ObjectProto[key];
defineProperty(o, key, descriptor);
defineProperty(ObjectProto, key, protoDescriptor);
};
}
that's a non-sense because you gonna always fallback instead of using native defineProperty
I would try to see how this goes:
try { // fails in few pre ES 5.1 engines
if (true === create(
defineProperty(
{},
prefix,
{
get: function () {
return defineProperty(this, prefix, {value: true})[prefix];
}
}
)
)[prefix]) {
setDescriptor = defineProperty;
} else {
throw 'IE11';
}
} catch(o_O) {
setDescriptor = function (o, key, descriptor) {
var protoDescriptor = gOPD(ObjectProto, key);
delete ObjectProto[key];
defineProperty(o, key, descriptor);
defineProperty(ObjectProto, key, protoDescriptor);
};
}
it would keep the fallback for those that throws errors and should de-opt IE11 only. Please let me know ( I can't test right now )
I'll test that now.
That works. 🎉
uhm ... I haven't actually closed this manually but most of all, I haven't bumped the version or published this to npm. If anyone can confirm this is fine, I'll be happy to do that.