Skip to content

Commit 74c9785

Browse files
committed
Fixed #1850: trace + debug cannot handle multi line comments
1 parent f0473c8 commit 74c9785

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/core/observable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ You are entering this break point because derivation '${derivation.name}' is bei
273273
Just follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update
274274
The stackframe you are looking for is at least ~6-8 stack-frames up.
275275
276-
${derivation instanceof ComputedValue ? derivation.derivation.toString() : ""}
276+
${derivation instanceof ComputedValue ? derivation.derivation.toString().replace(/[*]\//g, "/") : ""}
277277
278278
The dependencies for this derivation are:
279279

test/base/trace.js

+25
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ test("trace", () => {
1515
firstname: "Michel",
1616
lastname: "Weststrate",
1717
get fullname() {
18+
/* test multi line comment
19+
(run this unit test from VS code, and pass 'true' as third argument to trace below to verify)
20+
*/
1821
var res = this.firstname + " " + this.lastname
1922
mobx.trace(this, "fullname")
2023
return res
@@ -53,3 +56,25 @@ test("trace", () => {
5356
console.log = baselog
5457
}
5558
})
59+
60+
test("1850", () => {
61+
const x = mobx.observable({
62+
firstname: "Michel",
63+
lastname: "Weststrate",
64+
get fullname() {
65+
/* test multi line comment
66+
(run this unit test from VS code, to manually verify serialization)
67+
*/
68+
var res = this.firstname + " " + this.lastname
69+
mobx.trace(this, "fullname", true)
70+
return res
71+
}
72+
})
73+
74+
mobx.autorun(() => {
75+
x.fullname
76+
})
77+
expect(() => {
78+
x.firstname += "!"
79+
}).not.toThrow("Unexpected identifier")
80+
})

0 commit comments

Comments
 (0)