Skip to content

Commit

Permalink
Remove duplicate code (storybookjs#8285)
Browse files Browse the repository at this point in the history
Remove duplicate code
  • Loading branch information
ndelangen authored Oct 3, 2019
2 parents ead1e3d + 1d517d0 commit 8ee7fcd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
9 changes: 0 additions & 9 deletions app/react/src/client/preview/globals.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import { window } from 'global';

if (window && window.parent !== window) {
try {
// eslint-disable-next-line no-underscore-dangle
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
} catch (error) {
// The above line can throw if we do not have access to the parent frame -- i.e. cross origin
}
}

if (window) {
window.STORYBOOK_ENV = 'react';
}
10 changes: 0 additions & 10 deletions app/vue/src/client/preview/globals.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
/* eslint-disable no-underscore-dangle */
import { window } from 'global';

if (window.parent !== window) {
try {
window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
window.parent.__VUE_DEVTOOLS_CONTEXT__ = window.document;
} catch (error) {
// The above lines can throw if we do not have access to the parent frame -- i.e. cross origin
}
}

window.STORYBOOK_REACT_CLASSES = {};
window.STORYBOOK_ENV = 'vue';
7 changes: 3 additions & 4 deletions lib/core/src/server/templates/base-manager-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
/* globals window */
/* eslint-disable no-underscore-dangle */
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__;
if (window.top !== window) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.top.__REACT_DEVTOOLS_GLOBAL_HOOK__;
}
} catch (e) {
// eslint-disable-next-line no-console
console.warn('unable to connect to parent frame for connecting dev tools');
console.warn('unable to connect to top frame for connecting dev tools');
}
</script>
9 changes: 5 additions & 4 deletions lib/core/src/server/templates/base-preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@
/* globals window */
/* eslint-disable no-underscore-dangle */
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__;
if (window.top !== window) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.top.__REACT_DEVTOOLS_GLOBAL_HOOK__;
window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.top.__VUE_DEVTOOLS_GLOBAL_HOOK__;
window.top.__VUE_DEVTOOLS_CONTEXT__ = window.document;
}
} catch (e) {
// eslint-disable-next-line no-console
console.warn('unable to connect to parent frame for connecting dev tools');
console.warn('unable to connect to top frame for connecting dev tools');
}
</script>

0 comments on commit 8ee7fcd

Please sign in to comment.