Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-11-19 18:55:39 +03:00
parent 9d919187a5
commit 8a18714798

View File

@ -890,23 +890,27 @@ function Constructor(name, a, b, c){
&& obj.__init__(...arguments)
return obj }
// XXX this changes the name but does not seem to affect the displayed
// doc in chrome...
// FF does not seem to be affected by either version of code...
//Object.defineProperty(_constructor, 'name', { value: name })
// constructor naming...
// NOTE: we are not using:
// Object.defineProperty(_constructor, 'name', { value: name })
// because this does not affect the name displayed by the Chrome
// DevTools. FF does not seem to care about either version of code...
_constructor.name = name
// just in case the browser/node refuses to change the name, we'll make
// it a different offer ;)
// them a different offer ;)
// NOTE: this eval(..) should not be a risk as its inputs are
// static and never infuenced by external inputs...
// NOTE: this will fail with non-identifier names...
_constructor.name == 'Constructor'
// NOTE: this eval(..) should not be a risk as its inputs are
// static and never infuenced by external inputs...
// NOTE: this will fail with non-identifier names...
&& eval('_constructor = '+ _constructor
.toString()
.replace(/Constructor/g, name))
// set .toString(..)...
// NOTE: do this only if .toString(..) is not defined by user...
// XXX revise this test...
// NOTE: this test is here to enable mixinFlat(..) to overwrite
// .toString(..) below...
// XXX not sure if this is the correct approach...
// XXX might be a good idea to create a common base class and
// keep this there...
;((constructor_mixin || {}).toString === Function.prototype.toString
|| (constructor_mixin || {}).toString === Object.prototype.toString)
&& Object.defineProperty(_constructor, 'toString', {