jQuery 1.x is gone. Replace the uncompressed jquery-1.4.4 version with uncompressed jquery-2.1.3. Are also needed some changes in devel_library_alter

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

willzyx’s picture

pcambra’s picture

pcambra’s picture

Status: Needs review » Needs work

I think it should be hook_library_info_alter instead, according to this change record https://www.drupal.org/node/2391981

willzyx’s picture

Good catch. I'm investigating but I have some doubts about the best way to handle it..

Option 1 : replace jquery with our uncompressed version only if we found the file shipped with core.
Pro: the security that we are replacing the right file.
Cons: hardcoded jquery path, works only with jquery file shipped with core.

...
$minified = 'assets/vendor/jquery/jquery.min.js';

if (isset($libraries['jquery']['js'][$minified])) {
   $options = $libraries['jquery']['js'][$minified];
   unset($libraries['jquery']['js'][$minified]);

   $uncompressed = '/' . drupal_get_path('module', 'devel') . '/js/jquery-2.1.3-uncompressed.js';
   $libraries['jquery']['js'][$uncompressed] = array('minified' => FALSE);

   // To accurately replace jquery file the options have to be retained.
   $libraries['jquery']['js'][$uncompressed] += $options;
}
...

Option 2 : work with first element of $libraries['jquery']['js'] array.
Pro: no hardcoded path, works with already altered library
Cons: no security that we are replacing the right file. Some other module may have altered the library and changed the js array (is it realistic?)

...
$options = array_shift($libraries['jquery']['js']);
$uncompressed = '/' . drupal_get_path('module', 'devel') . '/js/jquery-2.1.3-uncompressed.js';
$libraries['jquery']['js'][$uncompressed] = array('minified' => FALSE);

// To accurately replace jquery file the options have to be retained.
$libraries['jquery']['js'][$uncompressed] += $options;
...

I am inclined to the first option.. @pcambra what do you think about?

willzyx’s picture

Status: Needs work » Needs review
FileSize
439.17 KB

I followed the first option

willzyx’s picture

@pcambra can you review, please? :)

pcambra’s picture

I guess that if jquery update or something similar is used for Drupal 8, we might encounter a conflict, but this might be good for now.

willzyx’s picture

Status: Needs review » Reviewed & tested by the community

Marking RTBC. See if anyone has objections, if not I'll commit it.

pcambra’s picture

I'm fine with it, but let's keep an eye on it to see if core provides a better way to do this at some point.

  • willzyx committed 5be43e1 on 8.x-1.x
    Issue #2409725 by willzyx: Remove jquery-1.4.4-uncompressed.js and add...
willzyx’s picture

Status: Reviewed & tested by the community » Fixed

I'll keep an eye on it to see if core provides a better way to do this

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.