0

运行时发现的循环引用JSON.stringify.

它检测到循环引用的对象在控制台中如下所示。

LOG|ES5|Object>>{
 "state": true,
 "model": "MAppAMDeleter",
 "client": {},
 "time": {},
 "bin": {
  "arg_this": {},        // I'm guessing this is the culprit
  "foo_id": "610"
 },
 "server": {
  "smalls": {
   "name": "The Foos",
   "page": "ma",
   "h_token": "1FOO",
   "remember": "0",
   "pane": "",
   "privacy": "0",
   "h_file": "1FOO",
   "picture": "1",
   "special": "0"
  },
  "tweets": {},
 }
}

我认为唯一可能导致错误的是我实际分配给对象文字的这一行。

pipe.bin.arg_this = this; // when I assign this, it points to a different object all together.

我试图理解为什么 Safari 会假设它指向包含结构化数据的对象文字(我在上面复制的那个),而 Firefox 似乎知道它指的是我分配它的初始对象 - 实际上是一个页面元素。

4

1 回答 1

1

试试这个:

....
initDynamic: function (event) {
    var pipe;
    event.preventDefault();
    pipe = $A.definePipe('MAppAMDeleter');
    pipe.bin.arg_this = event.target;                  // edited here.
    pipe.bin.arcmark_id = this.id;
    $A.machine(pipe);
}, ....

The reason is, that this can be overwritten by the time the javascript parser tries to fetch the object. different browsers handle JavaScript in (slightly) different ways, so one could be slightly faster fetching the clicked-object, whereas another one could be slower and read this as the latest class in charge ;)

event.target always points to the clicked object, no matter what ;)

于 2013-02-10T23:58:30.447 回答