1
0
Fork 0

Static property accessor method is no longer enumerable

closure/master
Mike Gerwitz 2011-05-11 20:53:43 -04:00
parent fa8d1bebe1
commit 9067bbf0cf
2 changed files with 24 additions and 2 deletions

View File

@ -661,7 +661,7 @@ function attachStatic( ctor, members, base, inheriting )
ctor.___$$sprops$$ = props;
// provide a method to access static properties
ctor.$ = function( prop, val )
util.defineSecureProp( ctor, '$', function( prop, val )
{
// we use hasOwnProperty to ensure that undefined values will not
// cause us to continue checking the parent, thereby potentially
@ -694,7 +694,7 @@ function attachStatic( ctor, members, base, inheriting )
// return the value
return props[ 'public' ][ prop ];
}
};
} );
}
// copy over public static methods

View File

@ -71,6 +71,28 @@ var common = require( './common' ),
} )();
/**
* If supported by the environment, ensure that the accessor method used to
* access static properties is not enumerable. It's unnecessary clutter (and
* confusion) otherwise.
*/
( function testStaticPropertyAccessorIsNotEnumerable()
{
var get = Object.getOwnPropertyDescriptor,
Foo = builder.build( {} );
// don't perform the test if unsupported
if ( fallback )
{
return;
}
assert.equal( get( Foo, '$' ).enumerable, false,
"Static property accessor method should not be enumerable"
);
} )();
/**
* Static members, by their nature, should be accessible through the class
* definition itself; that is, without instantiation. It should also not be