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
The trace function with last argument set to true enables to enter the debugger when re-evaluating traced derivation. If we trace a computed property with it's getter function body containing a multiline comment /* */, the browser throws SyntaxError: Unexpected identifier error.
The logTraceInfo function is reponsible for injecting an anonymous function containing the debugger statement generated from a string. If we use trace to trace a computed value, the computed value's getter function body is converted into a string with derivation.derivation.toString() and then inserted into a comment of the generated function. By not escaping the generated string a multi-line comment is inserted as-is, thus early closing a comment in the generated function.
Example of generated string from the attached sandbox:
debugger;
/*
Tracing '[email protected]'
You are entering this break point because derivation '[email protected]' is being traced and '[email protected]' is now forcing it to update.
Just follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update
The stackframe you are looking for is at least ~6-8 stack-frames up.
get fullName() {
/* multi-line comment */ <---------------- early closed comment
return `${this.firstName} ${this.lastName}`;
}
The dependencies for this derivation are:
[email protected][email protected][email protected]
*/
Escape (somehow) comments in the getter function's body string.
Inserting a space between closing comment tag (* /) should be enough. derivation.derivation.toString() -> derivation.derivation.toString().replace(/\*\//g, '* /')
The text was updated successfully, but these errors were encountered:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.
lockbot
locked as resolved and limited conversation to collaborators
Jul 21, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The trace function with last argument set to
true
enables to enter the debugger when re-evaluating traced derivation. If we trace a computed property with it's getter function body containing a multiline comment/* */
, the browser throwsSyntaxError: Unexpected identifier
error.The logTraceInfo function is reponsible for injecting an anonymous function containing the debugger statement generated from a string. If we use
trace
to trace a computed value, the computed value's getter function body is converted into a string with derivation.derivation.toString() and then inserted into a comment of the generated function. By not escaping the generated string a multi-line comment is inserted as-is, thus early closing a comment in the generated function.Example of generated string from the attached sandbox:
Sandbox to reproduce the issue:
https://codesandbox.io/s/v83p7xk80l
Suggested fix:
Escape (somehow) comments in the getter function's body string.
Inserting a space between closing comment tag (
* /
) should be enough.derivation.derivation.toString()
->derivation.derivation.toString().replace(/\*\//g, '* /')
The text was updated successfully, but these errors were encountered: