Fix issue with iframe targetWindow not being immediately available.
This commit is contained in:
parent
b937825747
commit
f69cee50e4
@ -2,11 +2,14 @@ class Connection
|
||||
constructor: (@target, @origin, @cb={}) ->
|
||||
$.on window, 'message', @onMessage
|
||||
|
||||
targetWindow: ->
|
||||
@target.contentWindow or @target
|
||||
|
||||
send: (data) =>
|
||||
@target.postMessage "#{g.NAMESPACE}#{JSON.stringify data}", @origin
|
||||
@targetWindow().postMessage "#{g.NAMESPACE}#{JSON.stringify data}", @origin
|
||||
|
||||
onMessage: (e) =>
|
||||
return unless e.source is @target and
|
||||
return unless e.source is @targetWindow() and
|
||||
e.origin is @origin and
|
||||
typeof e.data is 'string' and
|
||||
e.data[...g.NAMESPACE.length] is g.NAMESPACE
|
||||
|
||||
@ -98,7 +98,7 @@ Captcha.noscript =
|
||||
id: 'qr-captcha-iframe'
|
||||
src: @iframeURL()
|
||||
$.add QR.nodes.el, @nodes.iframe
|
||||
@conn.target = @nodes.iframe.contentWindow
|
||||
@conn.target = @nodes.iframe
|
||||
else if !@occupied or force
|
||||
@nodes.iframe.src = @iframeURL()
|
||||
@occupied = true
|
||||
|
||||
@ -96,7 +96,7 @@ Captcha.v2 =
|
||||
id: 'qr-captcha-iframe'
|
||||
src: @noscriptURL()
|
||||
$.add @nodes.container, iframe
|
||||
@conn.target = iframe.contentWindow
|
||||
@conn.target = iframe
|
||||
|
||||
setupJS: ->
|
||||
$.globalEval '''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user