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: Alias OffsetSize -> Offset #1288

Merged
merged 4 commits into from
Jul 11, 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
5 changes: 5 additions & 0 deletions example/child/frame.textarea.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
padding: 8px 10px;
border: solid 1px red;
}

textarea {
width: 40vw;
resize: vertical;
}
</style>
</head>

Expand Down
9 changes: 9 additions & 0 deletions packages/child/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ function readDataFromParent() {
}

function readDataFromPage() {
// eslint-disable-next-line sonarjs/cognitive-complexity
function readData() {
const data = window.iframeResizer || window.iFrameResizer

Expand All @@ -260,10 +261,18 @@ function readDataFromPage() {
onReady = data?.onReady || onReady

if (typeof data?.offset === 'number') {
advise(
`<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`,
)
if (calculateHeight) offsetHeight = data?.offset
if (calculateWidth) offsetWidth = data?.offset
}

if (typeof data?.offsetSize === 'number') {
if (calculateHeight) offsetHeight = data?.offsetSize
if (calculateWidth) offsetWidth = data?.offsetSize
}

if (Object.prototype.hasOwnProperty.call(data, 'sizeSelector')) {
sizeSelector = data.sizeSelector
}
Expand Down
11 changes: 9 additions & 2 deletions packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been rep
log(iframeId, 'Direction set to "vertical"')
}

function setOffset(offset) {
function setOffsetSize(offset) {
if (!offset) return
if (settings[iframeId].direction === 'vertical') {
settings[iframeId].offsetHeight = offset
Expand Down Expand Up @@ -1077,7 +1077,14 @@ The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been rep
}

setDirection()
setOffset(options?.offset)
setOffsetSize(options?.offsetSize || options?.offset)

if (options?.offset) {
advise(
`<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`,
)
}

getPostMessageTarget()

settings[iframeId].targetOrigin =
Expand Down
Loading