You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2021/11/29 13:55:00 UTC

[royale-asjs] branch develop updated: make postMessage easier

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 591e0f6  make postMessage easier
591e0f6 is described below

commit 591e0f618d31b746f1e45cec755e49400482e86d
Author: Harbs <ha...@in-tools.com>
AuthorDate: Mon Nov 29 15:54:48 2021 +0200

    make postMessage easier
---
 .../org/apache/royale/html/elements/Iframe.as      | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/frameworks/projects/HTML/src/main/royale/org/apache/royale/html/elements/Iframe.as b/frameworks/projects/HTML/src/main/royale/org/apache/royale/html/elements/Iframe.as
index 8d7b6f8..84ea6fd 100644
--- a/frameworks/projects/HTML/src/main/royale/org/apache/royale/html/elements/Iframe.as
+++ b/frameworks/projects/HTML/src/main/royale/org/apache/royale/html/elements/Iframe.as
@@ -243,6 +243,49 @@ package org.apache.royale.html.elements
 			}
 		}
 
+		/**
+		 * Convenience method for postMessage
+		 *  @langversion 3.0
+		 *  @productversion Royale 0.9.9
+		 */
+		public function postMessage(message:Object, targetOrigin:String, transfer:Object = null):void
+		{
+			COMPILE::JS
+			{
+				transfer = transfer || undefined;
+				contentWindow.postMessage(message,targetOrigin,transfer);
+			}
+		}
+
+		/**
+		 * Convenience method to attach message listener
+		 *  @langversion 3.0
+		 *  @productversion Royale 0.9.9
+		 */
+		public function addMessageListener(handler:Function):void
+		{
+			COMPILE::JS
+			{
+				contentWindow.addEventListener("message",handler);
+			}
+		}
+		
+		COMPILE::SWF
+		public function get contentWindow():Object
+		{
+			return null;			
+		}
+		/**
+		 * @royaleignorecoercion HTMLIFrameElement
+		 *  @langversion 3.0
+		 *  @productversion Royale 0.9.9
+		 */
+		COMPILE::JS
+		public function get contentWindow():Window
+		{
+			return (element as HTMLIFrameElement).contentWindow;
+		}
+
 		COMPILE::JS
 		override protected function createElement():WrappedHTMLElement
 		{