Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Use setTimeout(0) on events with void return type #1324

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/child/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function iframeResizerChild() {

sendTitle()
initEventListeners()
onReady()
setTimeout(onReady)

log('Initialization complete')
log('---')
Expand Down Expand Up @@ -1285,7 +1285,7 @@ The <b>size()</> method has been deprecated and replaced with <b>resize()</>. U
const msgBody = getData()
log(`PageInfo received from parent: ${msgBody}`)
if (onPageInfo) {
onPageInfo(JSON.parse(msgBody))
setTimeout(() => onPageInfo(JSON.parse(msgBody)))
} else {
// not expected, so cancel more messages
sendMsg(0, 0, 'pageInfoStop')
Expand All @@ -1297,7 +1297,7 @@ The <b>size()</> method has been deprecated and replaced with <b>resize()</>. U
const msgBody = getData()
log(`ParentInfo received from parent: ${msgBody}`)
if (onParentInfo) {
onParentInfo(Object.freeze(JSON.parse(msgBody)))
setTimeout(onParentInfo(Object.freeze(JSON.parse(msgBody))))
} else {
// not expected, so cancel more messages
sendMsg(0, 0, 'parentInfoStop')
Expand Down
8 changes: 4 additions & 4 deletions packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,13 @@ function chkEvent(iframeId, funcName, val) {
if (settings[iframeId]) {
func = settings[iframeId][funcName]

if (typeof func === 'function') {
retVal = func(val)
} else {
if (typeof func === 'function')
if (funcName === 'onClose' || funcName === 'onScroll') retVal = func(val)
else setTimeout(() => func(val))
else
throw new TypeError(
`${funcName} on iFrame[${iframeId}] is not a function`,
)
}
}

return retVal
Expand Down
Loading