You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FF ignores 'name'
V8 respects 'name' BUT it is used differently in trace produced by:
1) console.trace
2) throw "Test"
AND
3) (new Error).stack
4) <any code that results in uncaught error>
(1) and (2) simply present name's value as is
(3) and (4) prepend it with a class name if there's such
I belive this should be standardised (if someone could point me to the part of the proposal that deals with it - thanks in advance, I'm not good with them yet & simple text search for "class" in current specification yields 0 results)
While the current inconsistency makes getting always sensible stack trace for ES6 and framework-based OOP code impossible, I'm more concerned that the practice of prepending configurable "name" property with class name can become a standard.
As I understand, "name" was made configurable to let developers get meaningful stack traces for whatever OOP framework they use. Then (correct me if there're other use cases), the fact the "name" is used means developer takes full responsibility of how function name is represented in stack trace, it's not a browser's concern any more, so it must not prepend it with anything or process it in any other way.
In frameworks that have concept of extending a class, the factual constructor name is a generic "pre-constructor" function, hence factual full method names are similar to constructor.doThis and constructor.doThat ("constructor" instead of the real class name)
"name" allows framework to prefix method names with real class names, i.e. "ClassName.doThis", but trace (3) and (4) display it as "constructor.ClassName.doThis"
There's also a problem of static methods allowed by ES6.
V8 currently prepends them with "Function."
Obviously there should be a class name instead, but I cannot think of a representation that would satisfy everyone: both static and dynamic methods are called with . operator - how to clearly show which one it is?
Configurable "name" lets everyone choose whatever makes sense to them, i.e. show static one as A:a (vs. A.a) etc.
I am not sure though, if it's possible to say whether the configurable property has been modified or not.
If no, a simple solution would be to consider it modified if it is not a valid function name (this covers A.a and similar representations), though it feels hackish so I'm not sure browsers would want to implement it.
The text was updated successfully, but these errors were encountered:
Hello!
At the moment:
I belive this should be standardised (if someone could point me to the part of the proposal that deals with it - thanks in advance, I'm not good with them yet & simple text search for "class" in current specification yields 0 results)
While the current inconsistency makes getting always sensible stack trace for ES6 and framework-based OOP code impossible, I'm more concerned that the practice of prepending configurable "name" property with class name can become a standard.
As I understand, "name" was made configurable to let developers get meaningful stack traces for whatever OOP framework they use. Then (correct me if there're other use cases), the fact the "name" is used means developer takes full responsibility of how function name is represented in stack trace, it's not a browser's concern any more, so it must not prepend it with anything or process it in any other way.
In frameworks that have concept of extending a class, the factual constructor name is a generic "pre-constructor" function, hence factual full method names are similar to constructor.doThis and constructor.doThat ("constructor" instead of the real class name)
"name" allows framework to prefix method names with real class names, i.e. "ClassName.doThis", but trace (3) and (4) display it as "constructor.ClassName.doThis"
There's also a problem of static methods allowed by ES6.
V8 currently prepends them with "Function."
Obviously there should be a class name instead, but I cannot think of a representation that would satisfy everyone: both static and dynamic methods are called with . operator - how to clearly show which one it is?
Configurable "name" lets everyone choose whatever makes sense to them, i.e. show static one as A:a (vs. A.a) etc.
I am not sure though, if it's possible to say whether the configurable property has been modified or not.
If no, a simple solution would be to consider it modified if it is not a valid function name (this covers A.a and similar representations), though it feels hackish so I'm not sure browsers would want to implement it.
The text was updated successfully, but these errors were encountered: