From 446aa8d41388f5346bef1d334f21708726a858d0 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 4 Dec 2011 00:32:16 -0500 Subject: [PATCH] Fixed __self assignment for FF This little experience was rather frustrating. Indeed, it would imply that the static implementation (at least, accessing protected and private static members) was always broken in FF. I should be a bit more diligent in my testing. Or perhaps it broke in a more recent version of FF, which is more likely. The problem seems to be that we used defineSecureProp() for an assignment to the actual class, then later properly assigned it to class.___$$svis$$. Of course, defineSecureProp() makes it read-only, so this failed, causing an improper assignment for __self, breaking the implementation. As such, this probably broke in newer versions of FF and worked properly in older versions. More concerningly is that the implementations clearly differ between Chromium and Firefox. It may be that Firefox checks the prototype chain, whereas Chromium (v8, specifically) will simply write to that object, ignoring that the property further down the prototype chain is read-only. --- lib/ClassBuilder.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/ClassBuilder.js b/lib/ClassBuilder.js index 4c7b841..71005be 100644 --- a/lib/ClassBuilder.js +++ b/lib/ClassBuilder.js @@ -402,7 +402,7 @@ exports.prototype.build = function extend() // chain, it takes much more time to define the property in this manner. // Therefore, we can save a substantial amount of time by defining it on the // prototype rather than on each new instance via __initProps(). - util.defineSecureProp( prototype, '__self', new_class ); + util.defineSecureProp( prototype, '__self', new_class.___$$svis$$ ); // create internal metadata for the new class var meta = createMeta( new_class, base ); @@ -775,9 +775,6 @@ exports.prototype._attachPropInit = function( inst_props, properties, members ); - // give internal methods access to protected/private static members - vis.__self = ctor.___$$svis$$; - // provide a means to access the actual instance (rather than the // property/visibility object) internally (this will translate to // this.__inst from within a method), but only if we're on our final