iframe-resizer-react
iframe-resizer-react copied to clipboard
Invalid typings for `onResized` `width`
Issue
The typings for onResized indicate it receives numerical width.

However, when using it in the wild, the callback is invoked with a string value. In the implementation, width is never cast to a number.
https://github.com/davidjbradshaw/iframe-resizer/blob/master/src/iframeResizer.js#L162-L175
function processMsg() {
var data = msg.substr(msgIdLen).split(':')
var height = data[1] ? parseInt(data[1], 10) : 0
var iframe = settings[data[0]] && settings[data[0]].iframe
var compStyle = getComputedStyle(iframe)
return {
iframe: iframe,
id: data[0],
height: height + getPaddingEnds(compStyle) + getBorderEnds(compStyle),
width: data[2], // ← width is still a string
type: data[3]
}
}
Recommended Fix
Ideally, this could be fixed in the upstream iframe-resizer library so that width actually comes through as a number instead of a string. However, I recognize the far larger impact of such a change.
Alternatively, this consuming library could expect a string width without breaking backwards compatibility.
If you would like to fix the typings, I'd welcome the PR