Skip to content

Commit 7d0b4e8

Browse files
committed
JSON stringify data-source
1 parent 54ddba8 commit 7d0b4e8

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@
2626
```html
2727
<div
2828
id="app"
29-
data-source='"{
29+
data-source="{
3030
"filename": "root/src/App.vue",
3131
"start": 0,
3232
"end": 14
33-
}"'
33+
}"
3434
>
3535
<img
3636
alt="Vue logo"
3737
src="./assets/logo.png"
38-
data-source='"{
38+
data-source="{
3939
"filename": "root/src/App.vue",
4040
"start": 17,
4141
"end": 61
42-
}"'
42+
}"
4343
/>
4444
<h1
45-
data-source='"{
45+
data-source="{
4646
"filename": "root/src/HelloWorld.vue",
4747
"start": 22,
4848
"end": 26
49-
}"'
49+
}"
5050
>
5151
Welcome to Your Vue.js App
5252
</h1>

index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ const generateCompilerModule = () => {
55
const { start, end } = node;
66

77
const meta = { filename, start, end };
8-
const value = `"{\"filename\":\"${meta.filename}\",\"start\":${meta.start},\"end\":${meta.end}}"`;
8+
const value = JSON.stringify({
9+
filename: meta.filename,
10+
start: meta.start,
11+
end: meta.end,
12+
});
913

1014
if (!node.attrsList) node.attrsList = [];
1115
node.attrsList.push({ name: 'data-source', value: value });

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-source",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Add source location to elements",
55
"main": "index.js",
66
"scripts": {},

0 commit comments

Comments
 (0)