Add loop-protect

Remove webworkers
This commit is contained in:
Berkeley Martinez
2015-11-30 14:27:39 -08:00
parent 063d16383f
commit 3a299daa37
15 changed files with 597 additions and 513 deletions

View File

@@ -4,7 +4,13 @@ window.common = (function(global) {
common = { init: [] }
} = global;
// the first script tag here is to proxy jQuery
// We use the same jQuery on the main window but we change the
// context to that of the iframe.
var libraryIncludes = `
<script>
window.$ = parent.$.proxy(parent.$.fn.find, parent.$(document));
</script>
<link
rel='stylesheet'
href='//cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.min.css'
@@ -33,15 +39,10 @@ window.common = (function(global) {
// runPreviewTests$ should be set up in the preview window
common.runPreviewTests$ =
() => Observable.throw({ err: new Error('run preview not enabled') });
() => Observable.throw(new Error('run preview not enabled'));
common.updatePreview$ = function updatePreview$(code = '') {
const previewFrame = document.getElementById('preview');
const preview = previewFrame.contentDocument ||
previewFrame.contentWindow.document;
if (!preview) {
return Observable.just(code);
}
const preview = common.getIframe('preview');
return iFrameScript$
.map(script => `<script>${script}</script>`)
@@ -55,7 +56,10 @@ window.common = (function(global) {
// now we filter false values and wait for the first true
return common.previewReady$
.filter(ready => ready)
.first();
.first()
// the delay here is to give code within the iframe
// control to run
.delay(100);
})
.map(() => code);
};