Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
fix(tabs): $ref of webview got lost in dev-mode with HMR
Browse files Browse the repository at this point in the history
  • Loading branch information
herteleo committed Apr 20, 2019
1 parent efbc469 commit 8da78dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/TabMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default {
return this.$route.params.id === this.item.id;
},
webview() {
return this.$refs.webview.$refs.webview;
return this.$refs.webview.webview;
},
},
watch: {
Expand Down
15 changes: 9 additions & 6 deletions src/components/TabWebview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ export default {
windowHasFocus() {
return this.$store.getters['Window/hasFocus'];
},
webview() {
return this.$refs.webview;
},
},
watch: {
windowHasFocus(value) {
if (!this.muteOnWindowBlur) return;
this.$refs.webview.setAudioMuted(!value);
this.webview.setAudioMuted(!value);
},
},
mounted() {
this.$refs.webview.addEventListener('ipc-message', (event) => {
this.webview.addEventListener('ipc-message', (event) => {
if (event.channel !== 'notification') return;
const [notification] = event.args;
Expand All @@ -56,14 +59,14 @@ export default {
}
});
this.$refs.webview.addEventListener('page-title-updated', ({ title }) => {
this.webview.addEventListener('page-title-updated', ({ title }) => {
this.$store.commit('Pages/setState', {
tabId: this.item.id,
data: { title },
});
});
this.$refs.webview.addEventListener('page-favicon-updated', ({ favicons }) => {
this.webview.addEventListener('page-favicon-updated', ({ favicons }) => {
const [favicon] = favicons;
this.$store.commit('Pages/setState', {
Expand All @@ -72,7 +75,7 @@ export default {
});
});
this.$refs.webview.addEventListener('dom-ready', (view) => {
this.webview.addEventListener('dom-ready', (view) => {
if ('customCss' in this.item) {
view.target.insertCSS(this.item.customCss);
}
Expand All @@ -81,7 +84,7 @@ export default {
}
});
this.$refs.webview.addEventListener('new-window', (e) => {
this.webview.addEventListener('new-window', (e) => {
const { protocol } = url.parse(e.url);
if (protocol === 'http:' || protocol === 'https:') {
Expand Down

0 comments on commit 8da78dc

Please sign in to comment.