What's the reasoning behind the extra restrictions in [[CanPut]]?
[+google-caja-discuss]
Hi John,
First, thanks for commenting on repairES5.js. Please keep the comments coming. Anything not appropriate for the es-discuss like should instead be posted to google-caja-discuss, cc'ed. But please look instead at < code.google.com/p/es-lab/source/browse/trunk/src/ses/repairES5.js>,
which is the version in review at codereview.appspot.com/5489103.
Regarding this issue, thanks for raising it here. I was planning to do so myself, once I flesh out < strawman:fixing_override_mistake>.
But what's already there is coherent enough to look at.
The Irony of this "feature" of the language is that SES pays a significant performance penalty only on platforms that pass the test you link to. On platforms that fail this test, our "repair" in review at < code.google.com/p/es-lab/source/browse/trunk/src/ses/repairES5.js#2252>
makes them much faster.
So I was digging through repairES5.js code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/ses/repairES5.js#1427
and noticed that:
var a = Object.freeze({ 'x': 1 }); var b = Object.create(a); b.x = 2; b.x; // should still be 1
Then I dug into spec and noticed: es5.github.com/#x8.12.4
so
b.x
remains 1 because the property 'x' of its [[Prototype]] is writable: false.Ok, so why all of that when you could simply do:
var b = Object.create(a, { 'x': { 'configurable': true, 'enumerable': true, 'writable': true, 'value': 2 } });
or
Object.defineProperty(b, 'x', { 'configurable': true, 'enumerable': true, 'writable': true, 'value': 2 });
b.x; // 2