mirror of
https://github.com/chinchang/web-maker.git
synced 2025-08-05 04:47:32 +02:00
get back code to do inline style replacement when only css changes, instead of refreshing the page DOM
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
window.addEventListener('message', e => {
|
||||
// Recieving from app window
|
||||
if (e.data && e.data.contents && e.data.contents.match(/<html/)) {
|
||||
if (e.data && e.data.isCssOnly) {
|
||||
const frame = document.querySelector('iframe');
|
||||
if (
|
||||
frame.contentDocument &&
|
||||
frame.contentDocument.querySelector('#webmakerstyle')
|
||||
) {
|
||||
frame.contentDocument.querySelector('#webmakerstyle').textContent =
|
||||
e.data.css;
|
||||
}
|
||||
} else if (e.data && e.data.contents && e.data.contents.match(/<html/)) {
|
||||
const frame = document.querySelector('iframe');
|
||||
|
||||
frame.src = frame.src;
|
||||
setTimeout(() => {
|
||||
frame.contentDocument.open();
|
||||
@@ -9,6 +19,7 @@ window.addEventListener('message', e => {
|
||||
frame.contentDocument.close();
|
||||
}, 10);
|
||||
}
|
||||
// for files mode
|
||||
if (e.data && e.data.url && e.data.url.match(/index\.html/)) {
|
||||
document.querySelector('iframe').src = e.data.url;
|
||||
}
|
||||
|
Reference in New Issue
Block a user