You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2017/12/14 19:28:57 UTC

[GitHub] surajpindoria closed pull request #75: On WP 8.0 `execScript` need to be used instead of `eval`.

surajpindoria closed pull request #75: On WP 8.0 `execScript` need to be used instead of `eval`.
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/75
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs
index f5b7b1d5..c868501e 100644
--- a/src/wp/InAppBrowser.cs
+++ b/src/wp/InAppBrowser.cs
@@ -144,7 +144,7 @@ public void injectScriptCode(string options)
             {
                 Deployment.Current.Dispatcher.BeginInvoke(() =>
                 {
-                    var res = browser.InvokeScript("eval", new string[] { args[0] });
+                    var res = InvokeScript(args[0]);
 
                     if (bCallback)
                     {
@@ -229,6 +229,18 @@ private void ShowCordovaBrowser(string url)
             });
         }
 
+        private object InvokeScript(string script)
+        {
+            const string functionName = "__getInvokeScriptResult";
+            if (System.Environment.OSVersion.Version.Major == 8 && System.Environment.OSVersion.Version.Minor == 0)
+            {
+                browser.InvokeScript("execScript", new string[] { String.Format("var {0} = function(){{ return ({1}); }};", functionName, script) });
+                return browser.InvokeScript(functionName);
+            }
+
+            return browser.InvokeScript("eval", new [] { script });
+        }
+
 #if WP8
         private async void ShowSystemBrowser(string url)
         {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org