mirror of
https://github.com/chinchang/web-maker.git
synced 2025-03-22 19:49:40 +01:00
fix sandbox null issue
This commit is contained in:
parent
a35291b360
commit
4d45e85b90
@ -25,6 +25,8 @@ const PREVIEW_FRAME_HOST = window.DEBUG
|
||||
? 'http://localhost:7888'
|
||||
: `https://wbmakr.com`;
|
||||
|
||||
let cachedSandboxAttribute = '';
|
||||
|
||||
export default class ContentWrap extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@ -182,9 +184,11 @@ export default class ContentWrap extends Component {
|
||||
this.frame.src = this.frame.src;
|
||||
};
|
||||
const writeInsideIframe = () => {
|
||||
const sandbox = this.frame.getAttribute('sweet');
|
||||
console.log('setting back sandbox attr', sandbox);
|
||||
this.frame.setAttribute('sandbox', sandbox);
|
||||
if (!cachedSandboxAttribute && window.DEBUG) {
|
||||
alert('sandbox empty');
|
||||
}
|
||||
// console.log('setting back sandbox attr', sandbox);
|
||||
this.frame.setAttribute('sandbox', cachedSandboxAttribute);
|
||||
this.frame.removeAttribute('sweet');
|
||||
// console.log('sending postmessage');
|
||||
this.frame.contentWindow.postMessage({ contents }, '*');
|
||||
@ -193,9 +197,9 @@ export default class ContentWrap extends Component {
|
||||
// this.frame.contentDocument.close();
|
||||
};
|
||||
refreshAndDo(() => {
|
||||
const sandbox = this.frame.getAttribute('sandbox');
|
||||
console.log('removing sandbox', sandbox);
|
||||
this.frame.setAttribute('sweet', sandbox);
|
||||
cachedSandboxAttribute = this.frame.getAttribute('sandbox');
|
||||
// console.log('removing sandbox', sandbox);
|
||||
// this.frame.setAttribute('sweet', sandbox);
|
||||
this.frame.removeAttribute('sandbox');
|
||||
refreshAndDo(writeInsideIframe);
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
<script>
|
||||
function callback(e) {
|
||||
console.log('post message recvd', e.data);
|
||||
// console.log('post message recvd', e.data);
|
||||
window.document.open();
|
||||
|
||||
const { contents } = e.data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user