Skip to content

Commit

Permalink
Added: Enhanced no response warning to mention waitForLoad option if …
Browse files Browse the repository at this point in the history
…it is set to true
  • Loading branch information
davidjbradshaw committed Jul 11, 2024
1 parent 1ce531f commit e1d4e64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ <h2>Automagically resizing iFrame</h2>
// direction: 'none', // 'vertical' or 'horizontal' or 'none'
license: 'GPLv3',
log: true,
waitForLoad: true,

onResized(messageData) {
// Callback fn when resize is received
Expand Down
1 change: 1 addition & 0 deletions packages/common/filter-iframe-attribs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default (props) => {
scrolling,
tolerance,
warningTimeout,
waitForLoad,
onClosed,
onReady,
onMessage,
Expand Down
9 changes: 8 additions & 1 deletion packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ function trigger(calleeMsg, msg, id, noResponseWarning) {
function warnOnNoResponse() {
function warning() {
if (settings[id] === undefined) return // iframe has been closed while we where waiting
const { waitForLoad } = settings[id]

if (!settings[id].loaded && !settings[id].loadErrorShown) {
settings[id].loadErrorShown = true
Expand All @@ -799,7 +800,13 @@ function trigger(calleeMsg, msg, id, noResponseWarning) {
<rb>No response from iFrame</>
The iframe (<i>${id}</>) has not responded within ${settings[id].warningTimeout / 1000} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
${
waitForLoad
? `
The <b>waitForLoad</> option is currently set to <b>true</>. If the iframe loads before the JavaScript runs, this option will prevent <i>iframe-resizer</> from initialising. To disable this, set the <b>waitForLoad</> option to <b>false</>.
`
: ''
}
This message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.
`,
)
Expand Down

0 comments on commit e1d4e64

Please sign in to comment.