[Fix #37] constructor property now properly set on instances
parent
9dbd0d1fb3
commit
fa9dbcbf2e
|
@ -388,11 +388,11 @@ exports.prototype.build = function extend( _, __ )
|
|||
prototype, prop_init, members, new_class, this._classId
|
||||
);
|
||||
|
||||
new_class.prototype = prototype;
|
||||
new_class.constructor = new_class;
|
||||
new_class.___$$props$$ = prop_init;
|
||||
new_class.___$$methods$$ = members;
|
||||
new_class.___$$sinit$$ = staticInit;
|
||||
new_class.prototype = prototype;
|
||||
new_class.prototype.constructor = new_class;
|
||||
new_class.___$$props$$ = prop_init;
|
||||
new_class.___$$methods$$ = members;
|
||||
new_class.___$$sinit$$ = staticInit;
|
||||
|
||||
attachFlags( new_class, props );
|
||||
|
||||
|
@ -692,6 +692,7 @@ exports.prototype.createConcreteCtor = function( cname, members )
|
|||
)
|
||||
;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// provide a more intuitive string representation
|
||||
|
|
|
@ -167,3 +167,20 @@ assert.ok(
|
|||
}, TypeError, "Constructor cannot be private" );
|
||||
} )();
|
||||
|
||||
|
||||
/**
|
||||
* When a constructor is instantiated, the instance's 'constructor' property is
|
||||
* set to the constructor that was used to instantiate it. The same should be
|
||||
* true for class instances.
|
||||
*
|
||||
* This will also be important for reflection.
|
||||
*/
|
||||
( function testConsructorPropertyIsProperlySetToClass()
|
||||
{
|
||||
var Foo = Class( {} );
|
||||
|
||||
assert.ok( Foo().constructor === Foo,
|
||||
"Instance constructor should be set to class"
|
||||
);
|
||||
} )();
|
||||
|
||||
|
|
Loading…
Reference in New Issue