Skip to content

Commit c7f9f59

Browse files
author
Guillaume Chau
committed
Eval in webpage if possible
1 parent da9e6a4 commit c7f9f59

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/devtools/views/components/ComponentInspector.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,17 @@ export default {
7878
onTitleClick () {
7979
const file = this.target.file
8080
if (file) {
81-
fetch(`/_open?file=${file}`).then(() => {
82-
console.log(`File ${file} opened in editor`)
81+
const src = `fetch('/_open?file=${file}').then(() => {
82+
console.log('File ${file} opened in editor')
8383
}).catch(e => {
8484
console.warn(e)
85-
})
85+
})`
86+
if (chrome && chrome.devtools) {
87+
chrome.devtools.inspectedWindow.eval(src)
88+
} else {
89+
// eslint-disable-next-line no-eval
90+
eval(src)
91+
}
8692
}
8793
}
8894
}

0 commit comments

Comments
 (0)