Skip to content

Commit 558855f

Browse files
committed
Disable livereload in parent frame if present
When using a tool like [Viewport Resizer][], livereload is first injected in the main window, then when we transform this window into an embedded iframe, we get livereload loaded inside the iframe and outside the iframe. This means that we will reload both documents on HTML change and we will get kicked outside our iframe when the main window reload. This makes using [Viewport Resizer][] quite difficult. The solution proposed here is to disable liveloader in the parent frame if present. Only the inner iframe will keep livereloader. [Viewport Resizer]: http://lab.maltewassermann.com/viewport-resizer/
1 parent 00c2ced commit 558855f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/public/livereload.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,15 @@ __less = LessPlugin = (function() {
10311031
})();
10321032

10331033
// startup
1034-
var CustomEvents, LiveReload, k;
1034+
var CustomEvents, LiveReload, k, parent = window;
10351035
CustomEvents = __customevents;
10361036
LiveReload = window.LiveReload = new (__livereload.LiveReload)(window);
1037+
while (parent !== parent.parent) {
1038+
parent = parent.parent;
1039+
if (parent.LiveReload !== undefined) {
1040+
parent.LiveReload.shutDown();
1041+
}
1042+
}
10371043
for (k in window) {
10381044
if (k.match(/^LiveReloadPlugin/)) {
10391045
LiveReload.addPlugin(window[k]);

0 commit comments

Comments
 (0)