views:

53

answers:

2

Hi everyone,

For some reason, I am getting the following Javascript error in Internet Explorer 8 on line 3156 of jquery.js (version 1.4.3, non-compressed version): Object doesn't support this property or method. No error occurs in Firefox and Google Chrome.

This is the line the error occurs on:

if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {

Investigation (console.log(Expr.leftMatch[type])) produces the following interesting result: In Google Chrome, it outputs

/(^(?:.|\r|\n)*?):((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\3\))?(?![^\[]*\])(?![^\(]*\))/

However in Internet Explorer this is the output:

function() {
  var p = this;
  do p = p.previousSibling;
  while (p && p.nodeType != 1);
  return p;
}

On which exec cannot be called (it is undefined). The quoted function is not present within jquery.js. Does anyone have any clue why this happens, or what I can do to solve it?

I have, unfortunately, not yet been able to create a simple script to reproduce the problem, although I did find this post of someone having the same problem, but it does not offer a solution (the last post suggests the page should be run in Standards Mode, but mine already is).

A: 

what version of IE are you running?

Are you by some chance running in compatability mode? If you are testing on a local domain, by default IE sets compatability mode on, and ive experienced random wierd issues like this.

If you are running IE 8 you can try changing the browser mode in developer tools(f12) to see if the problem still persists.

brian brinley
Sorry, forgot to mention, I'm running IE8. It's running on a local webserver, and the developer tools report: `Documents Mode: IE8 Standards`.
Aistina
+2  A: 

As it turns out, I managed to figure it out by myself after several painful hours. It appears the Sizzle selector engine breaks in this unexpected way (and only in Internet Explorer), if you have defined Object.prototype.previousObject elsewhere.

Removing that declaration, or renaming previousObject to something else fixes the problem.

The funny thing is, I even put that code there myself (the Object.prototype.previousObject = [the function in my question]), but I did not recognize the code.

Well, that's another day full of development potential wasted.

Aistina
Wow. Well that's good to know, for sure!!
Pointy
x2 thanks for posting an update for everyone else.
brian brinley