Skip to content

Commit e5da901

Browse files
committed
clean up blocks2json a lil
1 parent 52bf2e2 commit e5da901

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

resources/js/block2json.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
//probably should put this in a local function on prod... fine for now tho
2-
3-
if (!String.prototype.startsWith) { // sweet polyfill
4-
String.prototype.startsWith = function(searchString, position) {
5-
position = position || 0;
6-
return this.indexOf(searchString, position) === position;
7-
};
8-
}
9-
101
function blockToCSS(blockList) {
112
function blockToCSS_(block) {
123
if(block.name == 'selector') {
@@ -82,8 +73,16 @@ function setFrameContent(ext) {
8273
blocksToJSON(currentFile);
8374

8475
var previewWindow = previewElement;
85-
previewWindow = (previewWindow.contentWindow) ? previewWindow.contentWindow : (previewWindow.contentDocument.document) ? previewWindow.contentDocument.document : previewWindow.contentDocument;
86-
while(previewWindow.document.firstChild) previewWindow.document.removeChild(previewWindow.document.firstChild);
76+
if(previewElement.contentWindow) {
77+
previewWindow = previewWindow.contentWindow;
78+
} else if(previewElement.contentDocument.document) {
79+
previewWindow = previewElement.contentDocument.document;
80+
} else {
81+
previewWindow = previewWindow.contentDocument
82+
}
83+
var previewDocument = previewWindow.document,
84+
child;
85+
while(child = previewDocument.firstChild) previewDocument.removeChild(child);
8786
previewWindow.document.appendChild(parsedHtml);
8887
} else {
8988
throw 'this should never be thrown though';

0 commit comments

Comments
 (0)