mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 02:20:08 +00:00
reworked the .name handling back -- neither chrome nor ff show the correct name otherwise...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f529fe54d8
commit
bed2eed2de
31
object.js
31
object.js
@ -217,7 +217,11 @@ function(obj){
|
||||
// NOTE: we just created func(..) so no need to sanitize it, the
|
||||
// only potential vector of atack (AFAIK) here is name and
|
||||
// that is checked above...
|
||||
Object.defineProperty(func, 'name', {value: name})
|
||||
func = eval('('+
|
||||
func
|
||||
.toString()
|
||||
.replace(/function\(/, `function ${name}(`) +')')
|
||||
//Object.defineProperty(func, 'name', {value: name})
|
||||
/* XXX NAME...
|
||||
//func.name = name
|
||||
func.name != name
|
||||
@ -916,28 +920,15 @@ function Constructor(name, a, b, c){
|
||||
obj.__init__ instanceof Function
|
||||
&& obj.__init__(...arguments)
|
||||
return obj }
|
||||
|
||||
// constructor naming...
|
||||
// rename the consructor...
|
||||
// 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...
|
||||
Object.defineProperty(_constructor, 'name', {value: name})
|
||||
/* XXX NAME...
|
||||
//_constructor.name = name
|
||||
// just in case the browser/node refuses to change the name, we'll make
|
||||
// them a different offer ;)
|
||||
// NOTE: it is not possible to abstract this eval(..) into something
|
||||
// like renameFunction(..) as reconstructing the function will
|
||||
// lose it's closure that we depend on here...
|
||||
// NOTE: this eval(..) should not be a risk as its inputs are
|
||||
// static and never infuenced by external inputs...
|
||||
_constructor.name != name
|
||||
&& (_constructor = eval('('+
|
||||
// because this does not affect the name displayed by the DevTools.
|
||||
_constructor = eval('('+
|
||||
_constructor
|
||||
.toString()
|
||||
.replace(/Constructor/g, name) +')'))
|
||||
//*/
|
||||
.replace(/Constructor/g, name) +')')
|
||||
|
||||
// set .toString(..)...
|
||||
// NOTE: this test is here to enable mixinFlat(..) to overwrite
|
||||
// .toString(..) below...
|
||||
@ -1309,6 +1300,8 @@ Constructor('Mixin', {
|
||||
// NOTE: we do not need to configure this any more, .defineProperty(..)
|
||||
// merges the descriptor into the original keeping any values not
|
||||
// explicitly overwritten...
|
||||
// XXX is this effective???
|
||||
// ...will this show up in DevTools???
|
||||
Object.defineProperty(this, 'name', { value: name })
|
||||
// create/merge .data...
|
||||
this.data = this.constructor.mixinFlat({},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-object",
|
||||
"version": "6.1.2",
|
||||
"version": "6.1.4",
|
||||
"description": "",
|
||||
"main": "object.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user