mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-07 16:48:02 +08:00
fix(email-frame): Refactor if/else for frame height
This commit is contained in:
parent
57c25b7fa9
commit
4efcbb4fc3
1 changed files with 7 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue