? Success

User tests: Successful: Unsuccessful:

avatar anibalsanchez
anibalsanchez
14 Feb 2014

Punycode.js has conditional code to declare itself as a RequireJS module (when RequireJS is previously loaded).

If other scripts declare RequireJS named modules, Punycode.js causes this error:

Error: Mismatched anonymous define() module: function () ...

https://groups.google.com/forum/#!searchin/joomla-dev-cms/punycode/joomla-dev-cms/ZdCfpSvXLsI/l7TssShte6MJ

To avoid this conflict, all RequireJS modules in Joomla core must be named modules.

In this case, the PR just defines Punycode name as 'punycode'.
define('punycode', function() ...

The change does not affect the regular form validation. (http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33105&start=0).

It only defines the module name if RequireJS is loaded.

Joomlacode: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33277&start=0

avatar anibalsanchez anibalsanchez - open - 14 Feb 2014
avatar infograf768
infograf768 - comment - 15 Feb 2014

As this is a change in the library itself, I suggest to rather propose it to the punycode original coder. Once accepted and the library updated by him, we should consider it.

avatar anibalsanchez
anibalsanchez - comment - 15 Feb 2014

Punycode developers can have a different opinion about named modules. It's a general practice to define un-named modules.

In the other hand, in Joomla, we can adopt a safe practice of naming modules to have a common standard for a future RequireJS adoption.

If not, you are forcing whom are currently using RequireJS to avoid Joomla form validation, or implement custom Javascript loading at the end of the head/body.

avatar infograf768
infograf768 - comment - 15 Feb 2014

My point is that, generally speaking, we do not modify 3rd party libraries as these may need to be updated when a new version of the library is released. In that case this change could be forgotten.

avatar anibalsanchez
anibalsanchez - comment - 15 Feb 2014

I agree with the general rule, but in this case punycode causes conflicts in a shared environment, where several actors can load scripts.

It's better if we use Javascript named modules practice. All JS modules in Joomla must have a defined name.

PD: We have already customized the whole Bootstrap to be friendly with MooTools modals. #1172

avatar mathiasbynens mathiasbynens - reference | - 17 Feb 14
avatar mathiasbynens
mathiasbynens - comment - 17 Feb 2014

Thanks for the report. You’re absolutely right, it makes no sense to do this for Punycode.js as we’re not trying to alias a competitor (contrary to e.g. Lo-Dash & Underscore.js). This is now fixed upstream in Punycode.js v1.2.4.

The reasoning matches that of jashkenas/underscore@d12b5be.

avatar infograf768
infograf768 - comment - 17 Feb 2014

Thanks @matiasbynens for replying so fast to my mail :)
As the original library was now corrected, we can now update it (with new version and including the (c)

avatar infograf768
infograf768 - comment - 17 Feb 2014

A there were other small changes I merged directly the new library (after testing :)
Thanks @anibalsanchez and Mathias

avatar infograf768 infograf768 - change - 17 Feb 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-02-17 08:30:40
avatar infograf768 infograf768 - close - 17 Feb 2014
avatar infograf768 infograf768 - close - 17 Feb 2014
avatar anibalsanchez
anibalsanchez - comment - 17 Feb 2014

Cool!

avatar mathiasbynens mathiasbynens - reference | 5db125e - 3 Jul 14
avatar mathiasbynens mathiasbynens - reference | fa77cc0 - 3 Jul 14
avatar mathiasbynens mathiasbynens - reference | 9609cfe - 3 Jul 14

Add a Comment

Login with GitHub to post a comment