Well, there are several reasons why this error appears...
I had this annoying error for a few days so I decided to track it down. It seems that in my case this error was a bug in jQuery.
if (document.documentElement.contains) {
Sizzle.contains = function (a, b) {
return a !== b && (a.contains ? a.contains(b) : true);
};
}
That code throws the exception in the a.contains(b) method call. So I tried to fix it for a while but I did not have a lot of time so I ended up patching it like:
if (document.documentElement.contains) {
Sizzle.contains = function (a, b) {
try {
return a !== b && (a.contains ? a.contains(b) : true);
}
catch (err) {
return false;
}
};
}
In my case it works. I know is not the best solution but if you are struggling with this it might help