ibm-js / ecma402

ECMA-402 JavaScript Internationalization API "shim"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IntlShim loads Intl in all cases

wkeese opened this issue · comments

After the latest check in of IntlShim.js I see multiple issues.

First, this line needs to execute the function, not just define the function. As you have it now __globalObject points to a function:

var __globalObject = (function(){return this;});

Thusly, this if condition is always true:

if (__globalObject.Intl === undefined) {
    dependencies.push("./Intl");
}

Finally, most importantly, the way to load modules conditionally is with the has! plugin. See requirejs doc for details. This method is non-standard and will break builds and cause other bad things to happen:

define(dependencies, ...

I agree with @wkeese that a has! plugin should be used. Although as far as I know, there is no has plugin for requirejs. An issue has been created to address that issue on ibm-js/sdk (ibm-js/sdk#8) but in the meantime you can use dojo/has instead (doc is here).

That should be a separate ticket though. I fixed the original problem listed here in e4275aa.