delete window[this.tipFnName]

越来越发现Ext的源码中很多地方对数据的有效性检验的不够好,甚至很多地方都没有检验便对其进行操作,例如Ext obj.ucountry is null错误。
这次遇到的错误是发生在Ext.chart.Chart组件,当在TabPanel的一个子Panel中使用了该组件并关闭当前的子Panel时,在火狐下不会有任何问题,而IE下则会报错,错误停留在源码中的delete window[this.tipFnName]这句上。
这个错误发生在销毁组件的方法中,源码如下:

onDestroy: function(){
    Ext.chart.Chart.superclass.onDestroy.call(this);
    delete window[this.tipFnName];
}

可以看到这里对this.tipFnName没有做任何判断便执行了delete操作。那么解决方法就很简单了:

Ext.override(Ext.chart.Chart, { 
    onDestroy: function(){ 
      Ext.chart.Chart.superclass.onDestroy.call(this); 
      if(this.tipFnName){
        delete window[this.tipFnName];
      }
    } 
});

除非另有声明,本站遵循【署名-非商业性使用-相同方式共享 3.0 共享协议】授权。

转载原创文章请注明,转载自:Neeke[http://www.ineeke.com]

本文链接: http://www.ineeke.com/archives/delete-window-this-tipfnname/

2009年12月24日 | 归档于 ExtJS | 5 条评论
标签: ,
  1. 2010年1月7日 18:05 | #1

    用GridPanel时出现’this.ds is undefined’,debug一下发现

    updateHeaderSortState : function(){
     var state = this.ds.getSortState();//这行报错了,ds是什么啊?
     if(!state){
     return;
     }
     if(!this.sortState || (this.sortState.field != state.field || this.sortState.direction != state.direction)){
     this.grid.fireEvent('sortchange', this.grid, state);
     }
     this.sortState = state;
     var sortColumn = this.cm.findColumnIndex(state.field);
     if(sortColumn != -1){
     var sortDir = state.direction;
     this.updateSortIcon(sortColumn, sortDir);
     }
     },
  2. 2009年12月25日 00:05 | #4

    第一个浏览第一个留言,对你不错吧 n:-wx

发表评论

XHTML: 您可以使用这些标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
n:-zy n:-zr n:-zan n:-xf n:-wx n:-tz n:-tt n:-ts n:-sy n:-st n:-ss n:-sk n:-qd n:-pz n:-lh n:-kun n:-ku n:-hx n:-hd n:-gt n:-gg n:-bz

NOTICE: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!