Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
04b0f00
Extract checkReadyYet from child
davidjbradshaw Oct 28, 2025
f5a746d
Extract quirks and version
davidjbradshaw Oct 28, 2025
4e5115d
extract stopInfiniteResize
davidjbradshaw Oct 28, 2025
ee7f607
Extract set CSS functions from child
davidjbradshaw Oct 28, 2025
93e57df
Extract applySelectors() and tidy file layout
davidjbradshaw Oct 28, 2025
62a6b3f
Extract settings and read functions
davidjbradshaw Oct 29, 2025
d9996e8
Extract checks from child
davidjbradshaw Oct 30, 2025
a940d80
Extract more checks
davidjbradshaw Oct 30, 2025
f734959
Extract more checks
davidjbradshaw Oct 30, 2025
51341d5
Extract check xDomain
davidjbradshaw Oct 30, 2025
59ad000
extract sendMessage()
davidjbradshaw Oct 30, 2025
e06cbc2
Extract ready()
davidjbradshaw Oct 31, 2025
9acbadc
Extract mouse events
davidjbradshaw Oct 31, 2025
bb46470
extract sendTitle
davidjbradshaw Oct 31, 2025
65429ec
tidy
davidjbradshaw Nov 1, 2025
9a60d0c
Extract size calc functions
davidjbradshaw Nov 1, 2025
ed56d0e
Tidy checks
davidjbradshaw Nov 1, 2025
915fa86
Tidy
davidjbradshaw Nov 1, 2025
32e9c70
Tidy
davidjbradshaw Nov 1, 2025
a75819b
Extract sendSize() & getContentSize()
davidjbradshaw Nov 1, 2025
d155840
Extract state values
davidjbradshaw Nov 1, 2025
6d9ec49
Extract ignored and overflow checks
davidjbradshaw Nov 1, 2025
f3b4c23
Extract onPageHIde
davidjbradshaw Nov 1, 2025
e81d6e0
Extract check H/W mode
davidjbradshaw Nov 2, 2025
6f01758
Extract user methods from child
davidjbradshaw Nov 3, 2025
7ed7ea7
Extract inPageLinks
davidjbradshaw Nov 3, 2025
8bfe416
Extract print events
davidjbradshaw Nov 3, 2025
5de0cf4
Extract utils
davidjbradshaw Nov 3, 2025
89b0651
Extract Observed and Init
davidjbradshaw Nov 3, 2025
9f28efa
extract received
davidjbradshaw Nov 3, 2025
03cee85
Tidy Received
davidjbradshaw Nov 3, 2025
d8261b1
Extract methods
davidjbradshaw Nov 4, 2025
7250f4d
Refactor child received
davidjbradshaw Nov 4, 2025
52d1a6f
Breakup received
davidjbradshaw Nov 4, 2025
ad00afd
Breakup Observers
davidjbradshaw Nov 4, 2025
169170d
Tidy Received
davidjbradshaw Nov 6, 2025
dec6fe5
Tidy Size
davidjbradshaw Nov 6, 2025
035ed89
Tidy
davidjbradshaw Nov 6, 2025
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AUTO } from '../common/consts'
import { advise, log } from './console'
import { AUTO } from '../../common/consts'
import { advise, log } from '../console'

const nodes = () => [document.documentElement, document.body]
const properties = ['min-height', 'min-width', 'max-height', 'max-width']
Expand Down
57 changes: 57 additions & 0 deletions packages/child/check/calculation-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { HIGHLIGHT } from 'auto-console-group'

import { advise, log, warn } from '../console'
import settings from '../values/settings'

const DEPRECATED_RESIZE_METHODS = {
bodyOffset: 1,
bodyScroll: 1,
offset: 1,
documentElementOffset: 1,
documentElementScroll: 1,
boundingClientRect: 1,
max: 1,
min: 1,
grow: 1,
lowestElement: 1,
}

const olderVersions = (
label,
) => `set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page. This can be done on the child page by adding the following code:

window.iframeResizer = {
license: 'xxxx',
${label}CalculationMethod: AUTO,
}
`

function showDeprecationWarning(label, calcMode) {
const actionMsg = settings.version
? 'remove this option.'
: olderVersions(label)

advise(
`<rb>Deprecated ${label}CalculationMethod (${calcMode})</>

This version of <i>iframe-resizer</> can auto detect the most suitable ${label} calculation method. It is recommended that you ${actionMsg}
`,
)
}

export default function checkCalcMode(calcMode, calcModeDefault, modes) {
const { label } = modes

if (calcModeDefault !== calcMode) {
if (!(calcMode in modes)) {
warn(`${calcMode} is not a valid option for ${label}CalculationMethod.`)
calcMode = calcModeDefault
}

if (calcMode in DEPRECATED_RESIZE_METHODS)
showDeprecationWarning(label, calcMode)
}

log(`Set ${label} calculation method: %c${calcMode}`, HIGHLIGHT)
return calcMode
}
22 changes: 22 additions & 0 deletions packages/child/check/deprecated-attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { SIZE_ATTR } from '../../common/consts'
import { advise } from '../console'

const DEPRECATED = `<rb>Deprecated Attributes</>

The <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.`

export default function checkDeprecatedAttrs() {
let found = false

const checkAttrs = (attr) =>
document.querySelectorAll(`[${attr}]`).forEach((el) => {
el.toggleAttribute(SIZE_ATTR, true)
el.removeAttribute(attr)
found = true
})

checkAttrs('data-iframe-height')
checkAttrs('data-iframe-width')

if (found) advise(DEPRECATED)
}
25 changes: 25 additions & 0 deletions packages/child/check/mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { VERSION } from '../../common/consts'
import setMode, { getModeData, getModeLabel } from '../../common/mode'
import { isDef } from '../../common/utils'
import { advise, purge, vInfo } from '../console'
import settings from '../values/settings'

export default function ({ key, key2, mode, version }) {
const oMode = mode
const pMode = setMode({ key })
const cMode = setMode({ key: key2 })
// eslint-disable-next-line no-multi-assign
settings.mode = mode = Math.max(pMode, cMode)
if (mode < 0) {
mode = Math.min(pMode, cMode)
purge()
advise(`${getModeData(mode + 2)}${getModeData(2)}`)
if (isDef(version))
throw getModeData(mode + 2).replace(/<\/?[a-z][^>]*>|<\/>/gi, '')
} else if (!isDef(version) || (oMode > -1 && mode > oMode)) {
if (sessionStorage.getItem('ifr') !== VERSION)
vInfo(`v${VERSION} (${getModeLabel(mode)})`, mode)
if (mode < 2) advise(getModeData(3))
sessionStorage.setItem('ifr', VERSION)
}
}
14 changes: 14 additions & 0 deletions packages/child/check/quirks-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { advise } from '../console'

export default function checkQuirksMode() {
if (document.compatMode !== 'BackCompat') return

advise(
`<rb>Quirks Mode Detected</>

This iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.

For more information see <u>https://iframe-resizer.com/quirks-mode</>.
`,
)
}
15 changes: 15 additions & 0 deletions packages/child/check/ready.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { READY_STATE_CHANGE } from '../../common/consts'
import { isolateUserCode } from '../../common/utils'
import { addEventListener } from '../page/listeners'

const COMPLETE = 'complete'
let readyChecked = false

export default function checkReadyYet(readyCallback) {
if (document.readyState === COMPLETE) isolateUserCode(readyCallback)
else if (!readyChecked)
addEventListener(document, READY_STATE_CHANGE, () =>
checkReadyYet(readyCallback),
)
readyChecked = true
}
27 changes: 27 additions & 0 deletions packages/child/check/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { FALSE, VERSION } from '../../common/consts'
import { advise } from '../console'

export default function checkVersion({ version }) {
if (!version || version === '' || version === FALSE) {
advise(
`<rb>Legacy version detected on parent page</>

Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.

See <u>https://iframe-resizer.com/setup/</> for more details.
`,
)
return
}

if (version !== VERSION) {
advise(
`<b>Version mismatch</>

The parent and child pages are running different versions of <i>iframe resizer</>.

Parent page: ${version} - Child page: ${VERSION}.
`,
)
}
}
7 changes: 0 additions & 7 deletions packages/child/from-string.js

This file was deleted.

37 changes: 0 additions & 37 deletions packages/child/from-string.test.js

This file was deleted.

Loading