From a06d9a7204f72da0dc8943c0f4dc4fba711aa721 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 16 Dec 2010 23:55:56 -0500 Subject: [PATCH] Ensured __initProps() is treated as a reserved method and cannot be declared within Classes --- lib/class.js | 11 +++++++++++ test/test-class-extend.js | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/class.js b/lib/class.js index 716b6d8..557ff5c 100644 --- a/lib/class.js +++ b/lib/class.js @@ -96,6 +96,17 @@ var extend = ( function( extending ) var properties = {}; 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 ) { properties[ name ] = value; diff --git a/test/test-class-extend.js b/test/test-class-extend.js index 8dccbfa..1e70c8e 100644 --- a/test/test-class-extend.js +++ b/test/test-class-extend.js @@ -185,3 +185,11 @@ assert.ok( "Subtypes can override parent property values" ); +assert.throws( function() +{ + Class.extend( + { + __initProps: function() {}, + }); +}, Error, "__initProps() cannot be declared (internal method)" ); +