Skip to content

Commit

Permalink
Add check for user set iframe title #1255
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjbradshaw committed Jun 7, 2024
1 parent 5b3758a commit 0644bdb
Show file tree
Hide file tree
Showing 2 changed files with 8 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 @@ -32,6 +32,7 @@ <h2>Automagically resizing iFrame</h2>
src="../child/frame.content.html"
width="100%"
scrolling="no"
title="iframe-resizer content examples"
></iframe>
</div>
<p id="callback"></p>
Expand Down
8 changes: 7 additions & 1 deletion packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
}

function setTitle(title, iframeId) {
if (!settings[iframeId]) return
if (!settings[iframeId]?.syncTitle) return
settings[iframeId].iframe.title = title
log(iframeId, `Set title attribute to: ${title}`)
}
Expand Down Expand Up @@ -1045,6 +1045,11 @@ The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been rep
settings[iframeId].postMessageTarget = iframe.contentWindow
}

function chkTitle(iframeId) {
const { title } = document.getElementById(iframeId)
return title === ''
}

function processOptions(options) {
settings[iframeId] = {
iframe,
Expand All @@ -1053,6 +1058,7 @@ The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been rep
...defaults,
...checkOptions(options),
mode: setMode(options),
syncTitle: chkTitle(iframeId),
}

setDirection()
Expand Down

0 comments on commit 0644bdb

Please sign in to comment.