fix(email-frame): Refactor if/else for frame height

This commit is contained in:
Jackie Luo 2016-11-02 15:56:27 -07:00
parent 57c25b7fa9
commit 4efcbb4fc3

View file

@ -102,19 +102,15 @@ export default class EmailFrame extends React.Component {
_getFrameHeight = (doc) => {
let height = 0;
if (doc && doc.body) {
// Why reset the height? body.scrollHeight will always be 0 if the height
// of the body is dependent on the iframe height e.g. if height ===
// 100% in inline styles or an email stylesheet
const style = window.getComputedStyle(doc.body)
if (style.height === '0px') {
doc.body.style.height = "auto"
}
}
// If documentElement has a scroll height, prioritize that as height
// If not, fall back to body scroll height by setting it to auto
if (doc && doc.documentElement && doc.documentElement.scrollHeight > 0) {
height = doc.documentElement.scrollHeight;
} else {
} else if (doc && doc.body) {
const style = window.getComputedStyle(doc.body);
if (style.height === '0px') {
doc.body.style.height = "auto";
}
height = doc.body.scrollHeight;
}