A question about Loader baseURL

Shijun He hax.sfo at gmail.com
Mon Aug 27 07:07:54 PDT 2012


On Mon, Aug 27, 2012 at 8:10 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
>> System.baseURL // "lib/a.js" ??
>
> No, the base url will be an absolute URL, like 'http://example.com/lib/a.js'.

So in /lib/b.js , System.baseURL will return a diff result
"http://example.com/lib/b.js" ?

>> var myLoader = new Loader(System, { baseURL: 'mypath/c.js' , fetch:myFetch })
>>
>> myLoader.baseURL // 'mypath/c.js' or 'lib/mypath/c.js' or any other value?
>
> 'mypath/c.js', which is what you provided as the 'baseURL'.
>
>> myLoader.load('b.js' ...) // load 'lib/mypath/b.js' or 'lib/b.js' ?
>
> Neither -- this invokes the `fetch` hook with relative url 'b.js', and
> the base url 'mypath/c.js' -- it's up to the fetch hook to determine
> what to do with it.  But 'lib' isn't in either of those arguments
> (although `myFetch` might contain a reference to `System.baseURL`).

So how do myLoader know what is the URL of the caller?! I mean:

I want:

/a/*.js
myLoader.load('test.js')  // load /a/test.js

/b/*.js
myLoader.load('test.js')  // load /b/test.js

But myFetch get the identical args: ('test.js', myLoader.baseURL)

HOW can myFetch know the correct URL? (Holding System.baseURL seems
useless in this case.)



>> and what happens if I call myLoader in other code for example which
>> url is '/otherpath/' ?
>
> I don't understand what you're asking here.

See above :)

--
hax


More information about the es-discuss mailing list