mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 15:15:12 +08:00
fix(frame): fix link clicking in iframes
This commit is contained in:
parent
11ed4781a4
commit
e42f501780
2 changed files with 14 additions and 2 deletions
|
@ -40,7 +40,9 @@ describe 'EventedIFrame', ->
|
|||
expect(@setAttributeSpy).not.toHaveBeenCalled()
|
||||
expect(@openLinkSpy).toHaveBeenCalled()
|
||||
target = @openLinkSpy.calls[i].args[0].target
|
||||
expect(target.getAttribute('href')).toBe href
|
||||
targetHref = @openLinkSpy.calls[i].args[0].href
|
||||
expect(target).not.toBeDefined()
|
||||
expect(targetHref).toBe href
|
||||
|
||||
it 'corrects relative uris', ->
|
||||
hrefs = [
|
||||
|
|
|
@ -150,8 +150,18 @@ class EventedIFrame extends React.Component
|
|||
else
|
||||
target.setAttribute('href', "http://#{rawHref}")
|
||||
|
||||
rawHref = target.getAttribute('href')
|
||||
|
||||
e.preventDefault()
|
||||
NylasEnv.windowEventHandler.openLink(target: target, metaKey: e.metaKey)
|
||||
|
||||
# It's important to send the raw `href` here instead of the target.
|
||||
# The `target` comes from the document context of the iframe, which
|
||||
# as of Electron 0.36.9, has different constructor function objects
|
||||
# in memory than the main execution context. This means that code
|
||||
# like `e.target instanceof Element` will erroneously return false
|
||||
# since the `e.target.constructor` and the `Element` function are
|
||||
# created in different contexts.
|
||||
NylasEnv.windowEventHandler.openLink(href: rawHref, metaKey: e.metaKey)
|
||||
|
||||
_isBlacklistedHref: (href) ->
|
||||
return (new RegExp(/^file:/i)).test(href)
|
||||
|
|
Loading…
Reference in a new issue