Skip to content

Commit

Permalink
Merge pull request #4199 from storybooks/fix/regression-cross-domain-…
Browse files Browse the repository at this point in the history
…devtool

FIX regression devtool, in case of cross domain parent, window.parent might throw
  • Loading branch information
pksunkara authored Sep 20, 2018
2 parents 825baf4 + 86e8dd4 commit 15711f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/core/src/server/templates/base-manager-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
</style>

<script>
if (window.parent !== window) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
try {
if (window.parent !== window) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
} catch (e) {
console.warn('unable to connect to parent frame for connecting dev tools');
}
</script>
10 changes: 7 additions & 3 deletions lib/core/src/server/templates/base-preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@
</style>

<script>
if (window.parent !== window) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
try {
if (window.parent !== window) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
} catch (e) {
console.warn('unable to connect to parent frame for connecting dev tools');
}
</script>

0 comments on commit 15711f1

Please sign in to comment.