'Can't find instance of 'jQuery.expr[":"]' while upgrading to jQuery 3.x
I'm in the process of upgrading from jQuery 1.11.2 to jQuery 3.1.1, using the jQuery-Migrate plugin version 3.0.0.
On every page load, I get this warning:
JQMIGRATE: jQuery.expr[":"] is now jQuery.expr.pseudos
The problem is that I can't find the offending code, or any variation of it, in either my code or 3rd party libraries. I did find this example, but I don't think it's the same?
$.fn.visible = function() {
return this.css('visibility', 'visible');
};
$.fn.invisible = function() {
return this.css('visibility', 'hidden');
};
Update 1: Here's the JS code loaded in a web page:
<!DOCTYPE html>
<html>
<head>
<title>UpgradeJquery</title>
<script src="/assets/jquery/jquery.min.js?body=1"></script>
<script src="/assets/jquery-migrate/jquery-migrate.js?body=1"></script>
<script src="/assets/jquery-ui/jquery-ui.min.js?body=1"></script>
<script src="/assets/application.js?body=1"></script>
</head>
<body>
<h1>Home#index</h1>
</body>
</html>
The snippet from my bower.json file that lists the versions:
"dependencies": {
"jquery": "^3.1.1",
"jquery-ui": "^1.12.1",
"jquery-migrate": "^3.0.0"
}
At this point I suspect jQuery-UI?
Solution 1:[1]
Open up the console in the browser, then expand the notice. Follow the stack trace from the top until you find the first file that isn't jquery-migrate or jquery. For example this issue is in tinymce.js on line 65
migrateWarn @ jquery-migrate-3.3.2.js?cache=da924a:102
get @ jquery-migrate-3.3.2.js?cache=da924a:113
(anonymous) @ jquery.tinymce.js?cache=da924a:65
(anonymous) @ jquery.tinymce.js?cache=da924a:91
The issue was fixed by changing
m.expr[":"]
to
m.expr.pseudos[":"]
Solution 2:[2]
:hidden Selector | jQuery API Documentation has changed it's meaning a little bit. But still works.
Normal programmers are not supposed to touch jQuery.expr.. It is not documented.
Are you using/writing code that creates new selectors? If not, you should not have to worry.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | George Cristian |
