Skip to content

Instantly share code, notes, and snippets.

Last active August 18, 2016 16:41
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save WebReflection/5370050 to your computer and use it in GitHub Desktop.
just __proto__ and all shenanigans it can bring to any environment
// all IE < 11 browsers:
// there is no __proto__
if (!('__proto__' in {})) {
console.log('you gonna have hard time');
// we need extra logic to be able to work
// as meant in IE too. IE9 ain't disappearing
// any time soon in both desktop and mobile
// neither will IE10
// all Mobile WebKit browsers:
// __proto__ is in null objects
if ('__proto__' in Object.create(null)) {
console.log('you gonna have hard time');
// if this is the case, the status is also
// that delete Object.prototype.__proto__
// will **not** be possible.
// There is no way to have a safe Dictionary
// or to do a table lookup.
// These browsers are about 70% of mobile
// all not so updated Chrome browsers plus many mobile browsers:
// cannot get rid of it
if (!Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').configurable) {
console.log('you gonna have hard time');
// is not possible to avoid the __proto__ evilness so
// any input or object[key] access should check
// key against "__proto__" or many undesired things
// could happen.
// Current status: nobody cares about this problem: fail!
// all not so updated Chrome browsers plus current node.js:
// can get rid, cannot reuse a part
if (!Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set) {
console.log('you gonna have hard time');
// if there is no setter to recycle there is no way to
// delete Object.prototype.__proto__ and be able to obtain
// later on the behavior via Object.setPrototypeOf()
// This is ... **was** the worst of all cases, you could drop it
// but you cannot trap/reuse its descriptor anywhere
// all updated Chrome browsers plus future node.js:
// can remove it, try to use it, and fail!
var set = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
if (set && typeof set === 'function') {
try {{}, {});
} catch(youGonnaBeKiddingMe) {
console.log('you gonna have hard time');
// this V8 poisons Object.prototype.__proto__
// descriptor in a way that will always throw.
// it looks like Firefox now but is unusable.
// It is not possible then to delete
// for security reason
// Object.prototype.__proto__ and reuse
// the descriptor.
// this is the best troll ever, well done V8
Copy link

clap clap clap

now ask yourself how good is for the web to promote early adoption of broken ideas so that the whole future of the language will get screwed.

I think it's called Butterfly Effect, and once again this is the best time ever to officially drop that property instead of promoting it!

P.S. all the community needed/wanted, wasn't a shame like that property in the Object.prototype but a way to subclass or swap class to native, untouchable, instances/constructors such NodeList and all non ArrayLike objects: nothing else, really!

Object.setPrototypeOf(obj, proto):obj was the simplest, most consistent, best way, to introduce this horrendous, and horrendously spec'd thing in the JS language.

Copy link

the sad Zepto attempt

I am unable to reply there so I'll do it here because the ball owner left the field offended.


This is also the reason I have removed my replies, if I cannot reply there and let people follow the discussion it does not make sense to have it broken.

@madrobby I came there with a 2 lines working patch that does not cause any side effect neither loss of performance asking understanding for an addressed issue nobody wants to deal with but is being considered a de-facto standard mainly because of that library on mobile (where for mobile, IE10 is not included)

I don't see many zepto developers in es-discuss mailing list so it was not about saving the world, rather informing you guys and asking you to consider this problem.

I had best intents and you think I've tried to do something just to take all the glory to rescue the world?
I am just a developer as you are and I thought the JS was a community, didn't know you mean it like a competition.

Apologies but with my statements I didn't mean to offend anyone there but to rather show facts about these kind of simple changes that should not "scare" TC39 or let them make weird decisions.

Epic fail, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment