fix(message): fix truncation of messages

It would seem the document.documentElement.scrollHeight can return 0 when
the document.body.scrollHeight reliably returns the correct height.
Changed to fallback to various height checking mechanisms.

Fixes #425
Fixes #1102
Fixes #1153
This commit is contained in:
Evan Morikawa 2016-01-28 18:07:43 -08:00
parent 8f384bb4e8
commit f0b0f35433

View file

@ -59,12 +59,15 @@ class EmailFrame extends React.Component
@refs.iframe.documentWasReplaced()
@_setFrameHeight()
_getFrameHeight: (doc) ->
return 0 unless doc
return doc.body?.scrollHeight ? doc.documentElement?.scrollHeight ? 0
_setFrameHeight: =>
return unless @_mounted
domNode = React.findDOMNode(@)
wrapper = domNode.contentDocument.getElementsByTagName('html')[0]
height = wrapper.scrollHeight
height = @_getFrameHeight(domNode.contentDocument)
# Why 5px? Some emails have elements with a height of 100%, and then put
# tracking pixels beneath that. In these scenarios, the scrollHeight of the
@ -74,7 +77,7 @@ class EmailFrame extends React.Component
domNode.height = "#{height}px"
@_lastComputedHeight = height
unless domNode?.contentDocument?.readyState is 'complete'
unless domNode.contentDocument?.readyState is 'complete'
_.defer => @_setFrameHeight()
_emailContent: =>