Static property accessor method is no longer enumerable
parent
fa8d1bebe1
commit
9067bbf0cf
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue