Question

This is a weird IE quirk. Here are the steps:

  1. Go to msn.com in Internet Explorer 8
  2. Pull up dev tools
  3. Switch Browser Mode to "IE8 Compat View"
  4. Switch Document Mode to "IE7 Standards"
  5. Switch to Script tab
  6. run the following script: true.toJSON()

it returns true. No other browser does this. It's giving me issues because it's causing the tooltip widget of jQueryUI to fail for IE because at some point it passes a boolean value of true to $.isEmptyObject(). Normally passing in true would just return true but since true now has a method associated with it (toJSON) it is returning false and breaking the widget.

I noticed there are some sites (like Google) that you can try to do the same test and true.toJSON() just breaks without returning anything. What is this weird toJSON method and how do I get rid of it?

Was it helpful?

Solution

From the jQuery.isEmptyObject() documentation:

The argument should always be a plain JavaScript Object as other types of object (DOM elements, primitive strings/numbers, host objects) may not give consistent results across browsers.

In other words, fix the tooltip widget.

OTHER TIPS

toJSON is a method that, if defined on an object, specifies the way JSON.stringify works on it. Check out MDN for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top