1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-25 07:51:12 +02:00

fix race conditions in preview

This commit is contained in:
Kushagra Gour
2024-05-04 23:53:28 +05:30
parent 27fe11eb67
commit e71979c5f5

View File

@@ -160,6 +160,7 @@ export default class ContentWrap extends Component {
trackEvent('fn', 'hasCode'); trackEvent('fn', 'hasCode');
trackEvent.hasTrackedCode = true; trackEvent.hasTrackedCode = true;
} }
console.log('writing start', html);
if (shouldInlineJs) { if (shouldInlineJs) {
if (this.detachedWindow) { if (this.detachedWindow) {
@@ -194,7 +195,7 @@ export default class ContentWrap extends Component {
// console.log('setting back sandbox attr', sandbox); // console.log('setting back sandbox attr', sandbox);
// this.frame.setAttribute('sandbox', cachedSandboxAttribute); // this.frame.setAttribute('sandbox', cachedSandboxAttribute);
// this.frame.removeAttribute('sweet'); // this.frame.removeAttribute('sweet');
// console.log('sending postmessage'); console.log('sending postmessage', html);
if (window.IS_EXTENSION) { if (window.IS_EXTENSION) {
this.frame.contentDocument.open(); this.frame.contentDocument.open();
this.frame.contentDocument.write(contents); this.frame.contentDocument.write(contents);
@@ -203,14 +204,14 @@ export default class ContentWrap extends Component {
this.frame.contentWindow.postMessage({ contents }, '*'); this.frame.contentWindow.postMessage({ contents }, '*');
} }
}; };
refreshAndDo(() => { // refreshAndDo(() => {
cachedSandboxAttribute = this.frame.getAttribute('sandbox'); // cachedSandboxAttribute = this.frame.getAttribute('sandbox');
// console.log('removing sandbox', sandbox); // // console.log('removing sandbox', sandbox);
// this.frame.setAttribute('sweet', sandbox); // // this.frame.setAttribute('sweet', sandbox);
// this.frame.removeAttribute('sandbox'); // // this.frame.removeAttribute('sandbox');
refreshAndDo(writeInsideIframe); // refreshAndDo(writeInsideIframe);
}); // });
// refreshAndDo(writeInsideIframe); refreshAndDo(writeInsideIframe);
} }
} else { } else {
// we need to store user script in external JS file to prevent inline-script // we need to store user script in external JS file to prevent inline-script