-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add location info to nodes #1501
Conversation
@@ -1,4 +1,4 @@ | |||
/* src/Main.html generated by Svelte v2.5.1 */ | |||
/* src/Main.html generated by Svelte v2.6.6 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we updated the CLI tests before they were merged in to replace the version number with x.y.z - when did that go away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we just changed the tests so that it would replace the version numbers when it compared the actual vs expected. would probably be better if it did that when the file is written, to avoid cluttering diffs
src/shared/utils.js
Outdated
} | ||
|
||
export function addLoc(element, file, line, column, char) { | ||
element.__svelte_meta = { file, line, column, char }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I was imagining that the loc data would live down inside an object under some key under __svelte_meta
, to keep it conceptually separated from other future non-loc data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah, that probably makes sense
src/compile/dom/index.ts
Outdated
@@ -100,6 +100,10 @@ export default function dom( | |||
builder.addBlock(compiler.javascript); | |||
} | |||
|
|||
if (compiler.options.dev) { | |||
builder.addLine(`const __file = ${JSON.stringify(compiler.file)};`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's of course very unlikely that anyone would use a variable called __file
, but it seems unwise to knowingly introduce potential conflicts, and I don't really see what this provides over simply including ${JSON.stringify(this.compiler.file)}
over when you generate code calling addLoc
from Element.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was just thinking it'd look less cluttered than having the filename repeated throughout the component. i guess we have the tools to pick a name that's guaranteed not to conflict, i was just being lazy
Fixes #1499.
Here's a short clip of this feature being used in Sapper Studio. The
App
pane has an edit icon, which takes you to the current page, and a crosshairs icon which lets you select a specific element.