From 289798866a332f52253c4c52f8d6874211d25611 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 18 Apr 2016 07:43:52 +0100 Subject: Wait for documentReady() when whoeing ui components. Previously, requests (like opening the Vomnibar) would be silently discarded if they arrive before the document is ready. Here, we queue them instead. --- content_scripts/ui_component.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index c7038f17..1a7a1634 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -67,12 +67,13 @@ class UIComponent when "hide" then @hide() else @handleMessage event - # Post a message (if provided), then call continuation (if provided). Because the constructor waits for - # documentReady(), @iframePort may not yet be ready. + # Post a message (if provided), then call continuation (if provided). We wait for documentReady() to ensure + # that the @iframePort set (so that we can use @iframePort.use()). postMessage: (message = null, continuation = null) -> - @iframePort?.use (port) => - port.postMessage message if message? - continuation?() + DomUtils.documentReady => + @iframePort.use (port) -> + port.postMessage message if message? + continuation?() activate: (@options = null) -> @postMessage @options, => -- cgit v1.2.3