-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: a.swap is not a function in form-validation.js:1:5199 w/ jQuery 1.12.0 #560
Comments
+1, I can reproduce this with the same configuration in Chrome 47 |
Looks like webshim is using an undocumented internal API function. Webshim needs to be updated to only call the public jQuery API functions. |
More info about the problem at aFarkas/webshim#560
Error is also occuring with the current jQuery2 version (2.2). Its working fine with jQuery 2.1 |
I ran across this issue after a Rails app was upgraded last week to address CVEs in a set of standard Gems. The packaged JQuery must have been bumped, which led to this function being hidden from the published API. For anybody needing a short term fix, I was able to regain the functionality by extracting the original JQuery code for .swap:
Not a long term fix, but maybe useful for others who suddenly have broken Rails apps. |
+1 |
Hi philayres, can you explain me where to declare swap function? |
I did exactly that and it worked -- make sure you are doing it after On Thu, Mar 10, 2016 at 10:24 AM, Christian Pradelli <
|
Thank you bruce, now it works, I made I typo when I copy the code. |
Same problem in IE11. Project using jQuery 2.2.1 and webshims 1.15.10. |
+1. Switching to jQuery 1.11.3 fixed the error. |
Hi, this is my first post in GitHub. I've encountered this issue using jQuery 3.x and I've found that webshims still only works with jQuery 1.8, after I've added jQuery-migrate the problem is fixed. |
Like mentioned above, you can just add the swap method: http://james.padolsey.com/jquery/#v=1.11.2&fn=jQuery.swap to your code to make this work. It has no other dependencies. $.swap = function (elem, options, callback, args) {
var ret, name, old = {};
// Remember the old values, and insert the new ones
for (name in options) {
old[name] = elem.style[name];
elem.style[name] = options[name];
}
ret = callback.apply(elem, args || []);
// Revert the old values
for (name in options) {
elem.style[name] = old[name];
}
return ret;
} |
After upgrading to 1.16.0 I was still able to reproduce this sometimes in Safari. Since this is the only thing I was using webshims for, I decided to ditch webshims in favor of a few lines of js based on http://codepen.io/ngault/pen/PqmyQE, and that's working better for me. (Now I'm free to upgrade to jQuery 3 too.) In case this helps anyone else here. |
Hi Alex,
When using the latest Webshim w/ the latest released jQuery 1.12.0, I get:
TypeError: a.swap is not a function
in form-validation.js line 1 char 5199.
This happens when I click on a field with type="month" or type="date" in Firefox 43.0.4 after initializing Webshim with:
The problem does not occur if I revert to jQuery 1.11.3.
I believe the issue is caused by this "fix" in jQuery 1.12:
jquery/jquery@0019a46
Thank you!
The text was updated successfully, but these errors were encountered: