Skip to content

Commit d2447fc

Browse files
committed
Fix #246 move iframe.contentWindow check inside the setTimeout
1 parent 5af2fce commit d2447fc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/utils/iframe.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ module.exports = {
7272
try {
7373
// When the iframe is not loaded, IE raises an exception
7474
// on 'contentWindow'.
75-
if (iframe && iframe.contentWindow) {
76-
setTimeout(function() {
75+
setTimeout(function() {
76+
if (iframe && iframe.contentWindow) {
7777
iframe.contentWindow.postMessage(msg, origin);
78-
}, 0);
79-
}
78+
}
79+
}, 0);
8080
} catch (x) {}
8181
};
8282

@@ -138,11 +138,11 @@ module.exports = {
138138
try {
139139
// When the iframe is not loaded, IE raises an exception
140140
// on 'contentWindow'.
141-
if (iframe && iframe.contentWindow) {
142-
setTimeout(function() {
143-
iframe.contentWindow.postMessage(msg, origin);
144-
}, 0);
145-
}
141+
setTimeout(function() {
142+
if (iframe && iframe.contentWindow) {
143+
iframe.contentWindow.postMessage(msg, origin);
144+
}
145+
}, 0);
146146
} catch (x) {}
147147
};
148148

0 commit comments

Comments
 (0)