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
35
object.js
35
object.js
@ -217,7 +217,11 @@ function(obj){
|
|||||||
// NOTE: we just created func(..) so no need to sanitize it, the
|
// NOTE: we just created func(..) so no need to sanitize it, the
|
||||||
// only potential vector of atack (AFAIK) here is name and
|
// only potential vector of atack (AFAIK) here is name and
|
||||||
// that is checked above...
|
// 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...
|
/* XXX NAME...
|
||||||
//func.name = name
|
//func.name = name
|
||||||
func.name != name
|
func.name != name
|
||||||
@ -916,28 +920,15 @@ function Constructor(name, a, b, c){
|
|||||||
obj.__init__ instanceof Function
|
obj.__init__ instanceof Function
|
||||||
&& obj.__init__(...arguments)
|
&& obj.__init__(...arguments)
|
||||||
return obj }
|
return obj }
|
||||||
|
// rename the consructor...
|
||||||
// constructor naming...
|
|
||||||
// NOTE: we are not using:
|
// NOTE: we are not using:
|
||||||
// Object.defineProperty(_constructor, 'name', { value: name })
|
// Object.defineProperty(_constructor, 'name', { value: name })
|
||||||
// because this does not affect the name displayed by the Chrome
|
// because this does not affect the name displayed by the DevTools.
|
||||||
// DevTools. FF does not seem to care about either version of code...
|
_constructor = eval('('+
|
||||||
Object.defineProperty(_constructor, 'name', {value: name})
|
_constructor
|
||||||
/* XXX NAME...
|
.toString()
|
||||||
//_constructor.name = name
|
.replace(/Constructor/g, 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('('+
|
|
||||||
_constructor
|
|
||||||
.toString()
|
|
||||||
.replace(/Constructor/g, name) +')'))
|
|
||||||
//*/
|
|
||||||
// set .toString(..)...
|
// set .toString(..)...
|
||||||
// NOTE: this test is here to enable mixinFlat(..) to overwrite
|
// NOTE: this test is here to enable mixinFlat(..) to overwrite
|
||||||
// .toString(..) below...
|
// .toString(..) below...
|
||||||
@ -1309,6 +1300,8 @@ Constructor('Mixin', {
|
|||||||
// NOTE: we do not need to configure this any more, .defineProperty(..)
|
// NOTE: we do not need to configure this any more, .defineProperty(..)
|
||||||
// merges the descriptor into the original keeping any values not
|
// merges the descriptor into the original keeping any values not
|
||||||
// explicitly overwritten...
|
// explicitly overwritten...
|
||||||
|
// XXX is this effective???
|
||||||
|
// ...will this show up in DevTools???
|
||||||
Object.defineProperty(this, 'name', { value: name })
|
Object.defineProperty(this, 'name', { value: name })
|
||||||
// create/merge .data...
|
// create/merge .data...
|
||||||
this.data = this.constructor.mixinFlat({},
|
this.data = this.constructor.mixinFlat({},
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-object",
|
"name": "ig-object",
|
||||||
"version": "6.1.2",
|
"version": "6.1.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "object.js",
|
"main": "object.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user