-
-
Notifications
You must be signed in to change notification settings - Fork 982
Refactor child #1550
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
Open
davidjbradshaw
wants to merge
38
commits into
master
Choose a base branch
from
refactor_child
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor child #1550
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 f5a746d
Extract quirks and version
davidjbradshaw 4e5115d
extract stopInfiniteResize
davidjbradshaw ee7f607
Extract set CSS functions from child
davidjbradshaw 93e57df
Extract applySelectors() and tidy file layout
davidjbradshaw 62a6b3f
Extract settings and read functions
davidjbradshaw d9996e8
Extract checks from child
davidjbradshaw a940d80
Extract more checks
davidjbradshaw f734959
Extract more checks
davidjbradshaw 51341d5
Extract check xDomain
davidjbradshaw 59ad000
extract sendMessage()
davidjbradshaw e06cbc2
Extract ready()
davidjbradshaw 9acbadc
Extract mouse events
davidjbradshaw bb46470
extract sendTitle
davidjbradshaw 65429ec
tidy
davidjbradshaw 9a60d0c
Extract size calc functions
davidjbradshaw ed56d0e
Tidy checks
davidjbradshaw 915fa86
Tidy
davidjbradshaw 32e9c70
Tidy
davidjbradshaw a75819b
Extract sendSize() & getContentSize()
davidjbradshaw d155840
Extract state values
davidjbradshaw 6d9ec49
Extract ignored and overflow checks
davidjbradshaw f3b4c23
Extract onPageHIde
davidjbradshaw e81d6e0
Extract check H/W mode
davidjbradshaw 6f01758
Extract user methods from child
davidjbradshaw 7ed7ea7
Extract inPageLinks
davidjbradshaw 8bfe416
Extract print events
davidjbradshaw 5de0cf4
Extract utils
davidjbradshaw 89b0651
Extract Observed and Init
davidjbradshaw 9f28efa
extract received
davidjbradshaw 03cee85
Tidy Received
davidjbradshaw d8261b1
Extract methods
davidjbradshaw 7250f4d
Refactor child received
davidjbradshaw 52d1a6f
Breakup received
davidjbradshaw ad00afd
Breakup Observers
davidjbradshaw 169170d
Tidy Received
davidjbradshaw dec6fe5
Tidy Size
davidjbradshaw 035ed89
Tidy
davidjbradshaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
packages/child/check-blocking-css.js → packages/child/check/blocking-css.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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</>. | ||
| `, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}. | ||
| `, | ||
| ) | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.