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