From the jQuery website:

jQuery Migrate Plugin

We have created the jQuery Migrate plugin to simplify the transition from older versions of jQuery. The plugin restores deprecated features and behaviors so that older code will still run properly on jQuery 1.9 and later. Use the uncompressed development version to diagnose compatibility issues, it will generate warnings on the console that you can use to identify and fix problems. Use the compressed production version to simply fix compatibility issues without generating console warnings.

I guess that would help people reduce rogue issues they might be having with various modules. We could put some sort of "Use the jQuery Migrate Plugin for enhanced compatibility" checkbox in the config page that is grayed out and enabled only when jQuery 1.9 and up is selected.

Edit: from the plugin's README.md @ GitHub:

The plugin can be included with versions of jQuery as old as 1.6.4 to identify potential upgrade issues via its JQMIGRATE console warnings. However, the plugin is only required for version 1.9.0 or higher to restore deprecated and removed functionality.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

klonos’s picture

Issue summary: View changes
GiorgosK’s picture

+1 for this feature
it would solve some problem when enabling 1.9 or higher versions

klonos’s picture

Cheers re patrida! ;)

mmikitka’s picture

mmikitka’s picture

Attached is a working patch with support for the jQuery Migrate Plugin. Here are a few notes:

  1. Supports CDN and local versions
  2. User can configure the Migrate Plugin API parameters
  3. The dev or production version is based on the same value used for the jQuery plugin
  4. Includes the latest version of jQuery Migrate; the end user cannot specify an earlier version
  5. If jQuery Migrate is enabled, it will be included for all jQuery versions supported by jquery_update, including those less than 1.9

Let me know your thoughts.

All the best,
matt

skadu’s picture

This looks great and works perfectly for me except for the CDN option. As discussed here: https://drupal.org/node/1905634 there has been an effort to load the CDN's from a protocoless URL which helps sites who are using either full SSL or mixed mode SSL load up the scripts over the appropriate scheme.

I made a minor change to the patch in #4 and it is attached:
New
$javascript['jquery.migrate']['js'][$local_path]['data'] = '//code.jquery.com/jquery-migrate-' . $version . $min . '.js';
Old
$javascript['jquery.migrate']['js'][$local_path]['data'] = 'http://code.jquery.com/jquery-migrate-' . $version . $min . '.js';

Thanks again for this, it really helps solve a headache where the accessible mega menus module requires jQuery 1.10, but the editor (WYSIWYG module using CkEditor, requires jQuery <= 1.8) which normally would be solved by using different verison on the admin side and the front end, but our client is editing the site using the front end theme, so this bridges the gap, thanks alot.

bkonetzny’s picture

Status: Active » Needs review
FileSize
31.38 KB

Added missing local files of jquery-migrate. Without them, only the CDN option is working.

gbirch’s picture

+1 for this feature request. Without the plugin, the wildly popular admin_menu module breaks in versions of jQuery above 1.8. And while it may get patched there (see https://drupal.org/node/2114587), there are lots of others out there.

phenaproxima’s picture

The patch in #7 works fine for me under jQuery 1.7.

s_leu’s picture

Can confirm that appliyng the patch in #7 and enabling the option "Enable jQuery Migrate Plugin" at admin/config/development/jquery_update is working. Had some trouble to apply the patch though:

$ patch -p1 < 2156881-jquery_update-jquery_migrate_support-7.patch 
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- jquery_update.module	2014-05-06 10:23:22.000000000 -0400
|+++ jquery_update.module	2014-05-08 14:09:27.000000000 -0400
--------------------------
File to patch:  

After entering jquery_update.module at the prompt the patch applied without any problems though. This should really get committed as without it admin menu breaks as gbirch already stated in #8.

omerida’s picture

Patch appiles fine, in jquery_update directory (note the-p0 to tell it not to strip any directories from the paths)

patch -p0 < 2156881-jquery_update-jquery_migrate_support-7.patch

mangy.fox’s picture

Applied patch #7, mostly works - except it put the jquery_migrate files in "b/replace/..." instead of just "replace/...".

Does anyone else get this, or have I done something stupid?

mangy.fox’s picture

Modified patch to remove "b/" from local file paths as rest of the patch works with -p0.

patch -p0 < 2156881-jquery_update-jquery_migrate_support-13.patch
(in jquery_update dir)

richard.thomas’s picture

I applied the patch from #13, and it worked but there were a few glitches I noticed:

The local copy was always included with the CDN version as there was no check before the document.write() call (I've added one).
Also I'm not sure why the migrate settings were included after the library, as it caused the console message "JQMIGRATE: Logging is active" to always show even when logging was not enabled (I've re-weighted that to before the libraries are included).

I've attached the updated patch, should work with -p1.

phamkhaclam90@gmail.com’s picture

@richard.thomas: thanks for your patch file in #14!
And I have little question, we must patching file in jquery_update dir or we can patching file in orther dir, eg: root dir of site?
Because when I patching in other dir, jquery-migrate dir is not copied into replace dir.

func0der’s picture

@Lam Pham
Almost all patch commands do have a parameter to change to directory to apply the patch from.
Just check the help sections ("--help") of those commands and you will find what you need ;)

rcodina’s picture

Patch on #14 works for me too. Thank you so much!!! This is a must have, I wish it gets commited ASAP.

marcoscano’s picture

patch #14 works for me as well

rcodina’s picture

Could be possible to add migrate plugin to admin pages too?

rcodina’s picture

Status: Needs review » Reviewed & tested by the community

Three good reviews means patch #14 works fine, so I RTBTC

RobLoach’s picture

I'm not actually sure we can commit the jQuery Migrate third-party code since it's MIT, and Drupal's Git Repository Usage has some policies surrounding that. I [pushed an issue into their queue](https://github.com/jquery/jquery-migrate/issues/74) to see what they say.

Sidebar: Maybe it's time we clean up the jQuery module so that third-party code is handled by Libraries?

EDIT: Too lazy to fix markdown, so here's the link: https://github.com/jquery/jquery-migrate/issues/74

RobLoach’s picture

Permission got!

func0der’s picture

MERGE ALL THE THINGS! ^^

jsibley’s picture

Any chance of getting this committed, since it has been tested and you have received permission from MIT?

Thanks.

fizk’s picture

@RobLoach Thanks for getting licensing permission. Are you able to commit this patch?

Elijah Lynn’s picture

Another RTBC from me!

markhalliwell’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Needs review

Moving to 7.x-3.x, will need review to ensure it still works well after #1969244: Specify jQuery version per theme.

rcodina’s picture

@markcarver Works for me!

fizk’s picture

Status: Needs review » Reviewed & tested by the community

Setting to RTBC based on #28.

bkonetzny’s picture

Previous patch from #14 didn't apply anymore for 7.x-2.x.
Re-rolled the patch which applies to 7.x-2.x and 7.x-3.x, please review.

rcodina’s picture

1) Just to clarify my comment on #28: I tested patch #14 with 7.x-3.x
2) Now I tested patch #30 with 7.x-3.x and also works fine
3) I wonder, wouldn't be a good idea to make jquery migrate enabled/disabled per theme?

markhalliwell’s picture

Assigned: Unassigned » markhalliwell

I'd like to review this in further detail later this week[end].

ram4nd’s picture

I would like that it would be automatic if you use combination of older UI and newer jQuery. But thanks #30 worked for me.

fizk’s picture

Status: Needs review » Reviewed & tested by the community

@markcarver If you found any issues, please let us know.

Setting to RTBC based on #31.

markhalliwell’s picture

Component: Miscellaneous » Code
Status: Reviewed & tested by the community » Needs review

I would still like to review this manually. I do not have time today, but will attempt to get to it sometime this week.

DrCord’s picture

This patch worked great for me! thanks so much!

eshta’s picture

This works for me too. Would love to see it in jquery_update since it is already our recommended solution for people. This would make it so that they don't have to deal with another javascript library too.

markhalliwell’s picture

I've reviewed the patch above, but encountered a few logistical issues I think need to be addressed. I also added #states to the sub-settings and only load it if the jQuery version is >= 1.9.

markhalliwell’s picture

Assigned: markhalliwell » Unassigned
kevinsullivan’s picture

I had JQuery Migrate working on an earlier version of a web site. I updated the JQuery Update module and lost the old patch. Recovering from backup isn't an option. I thus applied patch #38 in this thread to the current dev version of JQuery Update. The patch appears to have applied correctly, as I do now have a check-off for JQuery Migrate in my config panel for JQuery Update. I have checked the check-off to enable JQuery Migrate. However, it doesn't appear to be operating correctly. JQuery Migrate previously was the key to make FileDepot work on my site. Now it's no working, even with JQuery Migrate ostensibly enabled. Something appears to be at least partially working, as the Javascript for my rendered (FileDepot) page includes this:

jQuery.migrateMute=true;jQuery.migrateTrace=true;

. Is that all I should be seeing or should I be seeing the inclusion of a JQuery Migrate js file? With only this "migrate-related" code being run, my page is failing to fully load due to a javascript error encountered on an attempt to dereference the js "browser" variable. Any ideas where things might be failing? Let me know if there's anything I can do to help debug. --Kevin

mangy.fox’s picture

#38 works for me on 7.x-3.x-dev

@kevinsullivan with jQuery migrate enabled, the undefined 'browser' variable issue should be fixed. In fact this is the very reason I needed to include jQuery migrate in the first place.

Possibly silly question - are you using a jQuery version lower than 1.9?

If migrate was being included you would be able to see it in the head wherever your scripts are normally rendered - unless they are being aggregated of course.

kevinsullivan’s picture

Thank you #41. It is very strange. I worked for some time one night to get it to work. The next morning I got up and toggled the setting of the Jquery Migrate CDN, and lo and behold the darn thing worked. Yes, I had 1.9 set for user pages (lower for admin, but I was having the problems I was having on a user-facing page).

rcodina’s picture

Patch on #38 works for me too on 7.x-3.x-dev. Thanks mark!

kingfisher64’s picture

Brilliant #38 worked lovely on the latest dev.

Can this be committed?

rcodina’s picture

Status: Needs review » Reviewed & tested by the community

Given latest good reviews I mark this as RTBC.

Sneakyvv’s picture

FileSize
33.82 KB

The patch from #38 did not apply to 7.x-2.5, while patch from #30 did (and to 7.x-3.x-dev as well according to bkonetzny).

This patch is a re-roll of patch #38 so it applies to 7.x-2.5 again.

Sneakyvv’s picture

FileSize
33.85 KB

I didn't fully test my patch from #45 (re-roll from #38), since I was simply re-applying uncommitted patches after a "drush up". I noticed this issue was updated, and had a new patch that did not apply to 7.x-2.5 (7.x-2.x-dev seems not be available anymore).

Anyhow, my re-roll in #45 contains code that is not available in the 7.x-2.5 version (more specifically jquery_update_get_versions()), so it did not work as my client who reviewed their site update informed me. Working patch (for 7.x-2.5) attached.

markhalliwell’s picture

This feature will not be going into 7.x-2.x anymore (that branch will only contain security releases now). All future development is happening in 7.x-3.x.

rcodina’s picture

@markcarver I hope this gets commited in 7.x-3.x ASAP.

kingfisher64’s picture

Indeed rcodina, it's a strong solution to this problem. Bravo markcarver.

Sneakyvv’s picture

@markcarver: I understand, I liked your reviewed patch, and until there is a stable release for the 7.x-3.x branch, I'd think there should be patches for both versions. And now there is :)

aDarkling’s picture

#38 works for me on 7.x-3.x-dev
I have not specifically reviewed the code, though. Not familiar enough with the module.

RobLoach’s picture

  1. +++ b/jquery_update.module
    @@ -448,6 +512,79 @@ function jquery_update_jquery_backup(&$javascript, $path, $min, $version) {
    +        'weight' => -19.8,
    

    These weights are strange... There's one below that is -19.899999999.

  2. +++ b/jquery_update.module
    @@ -448,6 +512,79 @@ function jquery_update_jquery_backup(&$javascript, $path, $min, $version) {
    +    'weight' => -19.7999999999,
    

    Again, strange weight numbers. Could we use something that's not so awkwardly numbered?

markhalliwell’s picture

@RobLoach, this is following the existing pattern of code http://cgit.drupalcode.org/jquery_update/tree/jquery_update.module#n445

I too am not a fan per say, but this needs to be loaded right after jQuery. Do you have a different suggestion?

func0der’s picture

To all people that have used the patch from #14 and are using now #46 or try to do so.

If you have featured ANY of the settings from #14 you have to re-feature them with #46, because the variable names have changed ('plugin_' was removed).

Just a pit I have just fallen in :)

Christopher Riley’s picture

Patch does not seem to apply to latest dev. Has anyone rerolled the patch?

  • RobLoach committed 4605442 on 7.x-3.x
    Issue #2156881 by Sneakyvv, bkonetzny, markcarver, mangy.fox, mmikitka,...
RobLoach’s picture

Did a couple things....

1. Merged the patch
2. Resolved the conflict
3. Fixed a bug with the console warning variable name being wrong
4. Pushed it forwards to `7.x-3.x`

Thanks a lot, everyone! This is fantastic. Let's open up new issues for additional things before we get a `3.0-alpha1`.

RobLoach’s picture

Status: Reviewed & tested by the community » Fixed
DrCord’s picture

This is excellent, getting a stable version 3 out will be really great and @RobLoach is helping making it happen. Thanks!

Christopher Riley’s picture

Everything is working perfectly.....thank you for including the patch saves me so much time when developing.

Status: Fixed » Closed (fixed)

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

rcodina’s picture

With version 7.x-3.0-alpha2 of module, If I enable migrate plugin it doesn't get enabled. Someone reproduces the problem too?

rcodina’s picture

Status: Closed (fixed) » Needs review
Sneakyvv’s picture

Status: Needs review » Closed (fixed)

Please open a new issue for this.

rcodina’s picture

@Sneakyvv This issue is marked as fixed but this is not working on current recommended version of module. I think it's better to reopen this one.

Sneakyvv’s picture

I just installed jquery_update (drush dl jquery_update & drush en jquery_update -y) in a D7 sandbox and enabled the migrate plugin at /admin/config/development/jquery_update and the migrate script gets loaded.

  <script type="text/javascript" src="/sites/all/modules/contrib/jquery_update/replace/jquery/1.10/jquery.min.js?v=1.10.2"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.migrateMute=true;jQuery.migrateTrace=false;
//--><!]]>
</script>
<script type="text/javascript" src="/sites/all/modules/contrib/jquery_update/replace/jquery-migrate/1.2.1/jquery-migrate.min.js?v=1.2.1"></script>

So what exactly seems to be the problem you're having?

rcodina’s picture

@Sneakyvv Maybe it's other module/theme fault. I have to keep investigating this. In a clean install works for me too. But In one of my installs doesn't. My guess is that is Bootstrap theme fault.

rcodina’s picture

@Sneakyvv I just found which is the problem: If you leave the default jquery version (1.10) it works. If you switch to jQuery 1.8 migrate doesn't get included. So this is the problem. Do you reproduce it?

Sneakyvv’s picture

The description for the "enable checkbox" says "Even if jQuery Migrate is enabled, it will not be loaded if the current page's jQuery version is lower than 1.9.", which is obvious since the migrate plugin is all about making functions available which are deprecated since 1.9, so there's no point in enabling the migrate plugin for 1.8.

rcodina’s picture

@Sneakyvv Ok!