incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <...@adobe.com>
Subject Re: Mobile-spec cordova-js inclusion
Date Tue, 08 May 2012 19:33:03 GMT
Seems reasonable to me, Drew.

On 5/8/12 11:51 AM, "Drew Walters" <deedubbu@gmail.com> wrote:

>The mobile-spec cordova.js file [1] is the file referenced by all of
>the tests in the mobile-spec test suite. Its responsibilities
>currently are to load the actual cordova-js file and do any other
>setup (back button) that needs done. Right now, the versioned
>cordova-js file is included as follows to account for the fact that
>the test may be zero, one or two folders below the directory where it
>actually resides:
>
>    document.write('<script type="text/javascript" charset="utf-8"
>src="../../cordova-1.7.0.js"></script>');
>    document.write('<script type="text/javascript" charset="utf-8"
>src="../cordova-1.7.0.js"></script>');
>    document.write('<script type="text/javascript" charset="utf-8"
>src="cordova-1.7.0.js"></script>');
>
>On BlackBerry I'm noticing this results in cordova getting initialized
>multiple times even though only one of the relative paths is valid at
>a given time. For example, the initial test page loads
>cordova-1.7.0.js three times. If I go into a sub test, it gets loaded
>twice. This is because once the root is reached additional relative
>parent references are ignored. So for the initial test page all the
>'../' references get ignored and the file is loaded three times.
>
>Is this the behavior on other mobile platforms or is this BlackBerry /
>WebWorks specific?
>
>To get around this behavior, I've hacked my file to remove those three
>lines and instead do the following which determines the actual path to
>the file and only loads it once:
>
>    var scripts = document.getElementsByTagName('script');
>    var cordovaPath = scripts[scripts.length -
>1].src.replace('cordova.js', 'cordova-1.7.0.js');
>
>    document.write('<script type="text/javascript" charset="utf-8"
>src="' + cordovaPath + '"></script>');
>
>Any issues with doing this on the other platforms or is there a better
>way to guarantee the proper path is referenced and only loaded once?
>
>
>[1] 
>https://github.com/apache/incubator-cordova-mobile-spec/blob/master/cordov
>a.js


Mime
View raw message