Closed ewnjtgouierg closed 6 days ago
This proposal can’t force any changes on engines - in other words, we’re constrained to specify what they already do.
If there’s a single engine’s behavior that you think should be changed, then that engine needs to be convinced to change it.
thank you! Sorry, new to this
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.