From 8a18714798f788efd2d67a61792772a3246deb8d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 19 Nov 2020 18:55:39 +0300 Subject: [PATCH] notes... Signed-off-by: Alex A. Naanou --- object.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/object.js b/object.js index b644022..ec9a358 100755 --- a/object.js +++ b/object.js @@ -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', {