Skip to content

Commit

Permalink
Add deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjbradshaw committed Feb 15, 2019
1 parent d62ee9c commit eec3db9
Show file tree
Hide file tree
Showing 9 changed files with 909 additions and 1,213 deletions.
19 changes: 19 additions & 0 deletions js/iframeResizer.contentWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,30 @@
widthCalcMode = undefined !== data[14] ? data[14] : widthCalcMode
}

function depricate(key) {
var splitName = key.split('Callback')

if (splitName.length === 2) {
var name =
'on' + splitName[0].charAt(0).toUpperCase() + splitName[0].slice(1)
this[name] = this[key]
delete this[key]
warn(
"Deprecated: '" +
key +
"' has been renamed '" +
name +
"'. The old method will be removed in the next major version."
)
}
}

function readDataFromPage() {
function readData() {
var data = window.iFrameResizer

log('Reading data from page: ' + JSON.stringify(data))
Object.keys(data).forEach(depricate, data)

onMessage = 'onMessage' in data ? data.onMessage : onMessage
onReady = 'onReady' in data ? data.onReady : onReady
Expand Down
2 changes: 1 addition & 1 deletion js/iframeResizer.contentWindow.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/iframeResizer.contentWindow.min.js

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions js/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,25 @@
return '' === remoteHost || 'file://' === remoteHost ? '*' : remoteHost
}

function depricate(key) {
var splitName = key.split('Callback')

if (splitName.length === 2) {
var name =
'on' + splitName[0].charAt(0).toUpperCase() + splitName[0].slice(1)
this[name] = this[key]
delete this[key]
warn(
iframeId,
"Deprecated: '" +
key +
"' has been renamed '" +
name +
"'. The old method will be removed in the next major version."
)
}
}

function processOptions(options) {
options = options || {}
settings[iframeId] = {
Expand All @@ -1059,6 +1078,7 @@
}

checkOptions(options)
Object.keys(options).forEach(depricate, options)
copyOptions(options)

if (settings[iframeId]) {
Expand Down Expand Up @@ -1220,16 +1240,6 @@
addEventListener(document, 'visibilitychange', tabVisible)

addEventListener(document, '-webkit-visibilitychange', tabVisible)

// Andriod 4.4
addEventListener(window, 'focusin', function() {
resizeIFrames('focus')
})

// IE 9
addEventListener(window, 'focus', function() {
resizeIFrames('focus')
})
}

function factory() {
Expand Down
2 changes: 1 addition & 1 deletion js/iframeResizer.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/iframeResizer.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit eec3db9

Please sign in to comment.