Remove duplicate code (#8285)

Remove duplicate code
This commit is contained in:
Norbert de Langen 2019-10-03 19:49:54 +02:00 committed by GitHub
commit 8ee7fcd283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 27 deletions

View File

@ -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';
}

View File

@ -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';

View File

@ -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>

View File

@ -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>