One last note to make it clear, if you use static initializers like that you 
don’t need <inject_script> at all.

From: Yishay Weiss<mailto:yishayj...@hotmail.com>
Sent: Saturday, May 16, 2020 2:47 PM
To: users@royale.apache.org<mailto:users@royale.apache.org>
Subject: RE: Heads Up: <inject_html> was replaced with <inject_script>

Should be getJs():String{} and getCss():String{}

From: Yishay Weiss<mailto:yishayj...@hotmail.com>
Sent: Saturday, May 16, 2020 2:42 PM
To: users@royale.apache.org<mailto:users@royale.apache.org>
Subject: RE: Heads Up: <inject_html> was replaced with <inject_script>

To avoid errors in the console and have more control over this in your app, you 
can probably use static initializers. For example (not tested),

package A
{
                import org.apache.royale.utils.css.loadCSS;
                import org.apache.royale.utils.js.loadJavascript;
                public class B
                {
                                private static var jsId:String = getJs();
                                private static var cssId:String = getCss();
                                private static var jsLoaded:Boolean;
                                private static var cssLoaded:Boolean;

                                private static function getJs():Boolean
                                {
                                                return 
loadJavascript(“http://myLib.js”, raiseJsLoadedFlag);
                                }

                                private static function getCss():Boolean
                                {
                                                return 
loadCSS("http://myLib.css”, raiseCssLoadedFlag);
                                }

                                private static function raiseJsLoadedFlag():void
                                {
                                                jsLoaded = true;
                                }

                                private static function 
raiseCssLoadedFlag():void
                                {
                                                cssLoaded = true;
                                }

                                public function doLibStuff():void
                                {
                                                if (jsLoaded && cssLoaded)
                                                {
                                                                // call lib api
                                                } else
                                                {
                                                                // warn user 
lib hasn't been loaded yet
                                                }
                                }
                }
}

This also allows for a conditional load based on BrowserInfo.

From: Yishay Weiss<mailto:yishayj...@hotmail.com>
Sent: Saturday, May 16, 2020 2:04 PM
To: users@royale.apache.org<mailto:users@royale.apache.org>
Subject: RE: Heads Up: <inject_html> was replaced with <inject_script>

Ok, I’m seeing it now. It looks like there’s a race condition that only 
manifests in release mode because the app initializes quicker. The good news is 
that window[“dialogPolyfill”], window[“hljs”], etc. do eventually load in 
release as well, so I don’t think there will be functional implications unless 
your code calls these objects on initialization.



From: Carlos Rovira <carlosrov...@apache.org>
Sent: Saturday, May 16, 2020 1:18:20 PM
To: users@royale.apache.org <users@royale.apache.org>
Subject: Re: Heads Up: <inject_html> was replaced with <inject_script>

Hi, I think the problems is only in release not in debug mode

El sáb., 16 may. 2020 a las 12:17, Carlos Rovira 
(<carlosrov...@apache.org<mailto:carlosrov...@apache.org>>) escribió:
Hi Yishay,
yes I build all days before starting


El sáb., 16 may. 2020 a las 11:54, Yishay Weiss 
(<yishayj...@hotmail.com<mailto:yishayj...@hotmail.com>>) escribió:

Are you sure you updated both the compiler and asjs? I did test Alert.



From: Carlos Rovira <carlosrov...@apache.org<mailto:carlosrov...@apache.org>>
Sent: Saturday, May 16, 2020 12:50:43 PM
To: users@royale.apache.org<mailto:users@royale.apache.org> 
<users@royale.apache.org<mailto:users@royale.apache.org>>
Subject: Re: Heads Up: <inject_html> was replaced with <inject_script>

Hi Yishay,

I'm seeing in TDJ this error when running:

ReferenceError: dialogPolyfill is not defined
    at 
/Users/carlosrovira/Dev/Royale/Source/royale-asjs/examples/jewel/TourDeJewel/target/javascript/bin/js-debug/App.js:10:1

Although Alert seems to work. Maybe dialogPolyfill is not needed anymore?

How can that error be removed?



El vie., 15 may. 2020 a las 17:26, Yishay Weiss 
(<yishayj...@hotmail.com<mailto:yishayj...@hotmail.com>>) escribió:

Hi,



A heads-up in case your application uses <inject_html>. Due to a bug [1] that 
was found when loading modules on IE <inject_html> was deprecated in favor of 
<inject_script>. So if you’ve used <inject_html> to add html elements to your 
application, please convert it to add js instead.



For example,





         * <inject_html>

         * <script 
src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js<http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js>"></script>

         * <link rel="stylesheet" 
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css<http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css>">

         * </inject_html>



Should be converted to be



         * <inject_script>

         * var script = document.createElement("script");

         * script.setAttribute("src", 
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js";);

                                * document.head.appendChild(script);

         * var link = document.createElement("link");

         * link.setAttribute("rel", "stylesheet");

         * link.setAttribute("type", "text/css");

         * link.setAttribute("href", 
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css";);

         * document.head.appendChild(link);

         * </inject_script>



Thanks,

Yishay



[1] https://github.com/apache/royale-asjs/issues/826




--
Carlos Rovira
http://about.me/carlosrovira



--
Carlos Rovira
http://about.me/carlosrovira



--
Carlos Rovira
http://about.me/carlosrovira

From: Carlos Rovira<mailto:carlosrov...@apache.org>
Sent: Saturday, May 16, 2020 1:18 PM
To: users@royale.apache.org<mailto:users@royale.apache.org>
Subject: Re: Heads Up: <inject_html> was replaced with <inject_script>

Hi, I think the problems is only in release not in debug mode

El sáb., 16 may. 2020 a las 12:17, Carlos Rovira 
(<carlosrov...@apache.org<mailto:carlosrov...@apache.org>>) escribió:
Hi Yishay,
yes I build all days before starting


El sáb., 16 may. 2020 a las 11:54, Yishay Weiss 
(<yishayj...@hotmail.com<mailto:yishayj...@hotmail.com>>) escribió:
Are you sure you updated both the compiler and asjs? I did test Alert.


From: Carlos Rovira <carlosrov...@apache.org<mailto:carlosrov...@apache.org>>
Sent: Saturday, May 16, 2020 12:50:43 PM
To: users@royale.apache.org<mailto:users@royale.apache.org> 
<users@royale.apache.org<mailto:users@royale.apache.org>>
Subject: Re: Heads Up: <inject_html> was replaced with <inject_script>

Hi Yishay,

I'm seeing in TDJ this error when running:

ReferenceError: dialogPolyfill is not defined
    at 
/Users/carlosrovira/Dev/Royale/Source/royale-asjs/examples/jewel/TourDeJewel/target/javascript/bin/js-debug/App.js:10:1

Although Alert seems to work. Maybe dialogPolyfill is not needed anymore?

How can that error be removed?



El vie., 15 may. 2020 a las 17:26, Yishay Weiss 
(<yishayj...@hotmail.com<mailto:yishayj...@hotmail.com>>) escribió:

Hi,



A heads-up in case your application uses <inject_html>. Due to a bug [1] that 
was found when loading modules on IE <inject_html> was deprecated in favor of 
<inject_script>. So if you’ve used <inject_html> to add html elements to your 
application, please convert it to add js instead.



For example,





         * <inject_html>

         * <script 
src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js<http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js>"></script>

         * <link rel="stylesheet" 
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css<http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css>">

         * </inject_html>



Should be converted to be



         * <inject_script>

         * var script = document.createElement("script");

         * script.setAttribute("src", 
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js";);

                                * document.head.appendChild(script);

         * var link = document.createElement("link");

         * link.setAttribute("rel", "stylesheet");

         * link.setAttribute("type", "text/css");

         * link.setAttribute("href", 
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css";);

         * document.head.appendChild(link);

         * </inject_script>



Thanks,

Yishay



[1] https://github.com/apache/royale-asjs/issues/826




--
Carlos Rovira
http://about.me/carlosrovira



--
Carlos Rovira
http://about.me/carlosrovira



--
Carlos Rovira
http://about.me/carlosrovira





Reply via email to