Ensured __initProps() is treated as a reserved method and cannot be declared within Classes
parent
a60fe9c2de
commit
a06d9a7204
11
lib/class.js
11
lib/class.js
|
@ -96,6 +96,17 @@ var extend = ( function( extending )
|
||||||
|
|
||||||
var properties = {};
|
var properties = {};
|
||||||
util.propCopy( props, prototype, result_data, {
|
util.propCopy( props, prototype, result_data, {
|
||||||
|
each: function( name, value )
|
||||||
|
{
|
||||||
|
// disallow use of our internal __initProps() method
|
||||||
|
if ( name === '__initProps' )
|
||||||
|
{
|
||||||
|
throw new Error( "__initProps is a reserved method" );
|
||||||
|
}
|
||||||
|
|
||||||
|
this.performDefault( name, value );
|
||||||
|
},
|
||||||
|
|
||||||
property: function( name, value )
|
property: function( name, value )
|
||||||
{
|
{
|
||||||
properties[ name ] = value;
|
properties[ name ] = value;
|
||||||
|
|
|
@ -185,3 +185,11 @@ assert.ok(
|
||||||
"Subtypes can override parent property values"
|
"Subtypes can override parent property values"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.throws( function()
|
||||||
|
{
|
||||||
|
Class.extend(
|
||||||
|
{
|
||||||
|
__initProps: function() {},
|
||||||
|
});
|
||||||
|
}, Error, "__initProps() cannot be declared (internal method)" );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue