2

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?

4

2 回答 2

2

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.

于 2013-02-22T02:33:35.370 回答
0

toJSON是一种方法,如果在对象上定义,则指定对其进行操作的方式JSON.stringify。查看MDN了解更多详情。

于 2013-02-22T02:23:03.433 回答