Firefox 18 javascript编译器 IonMonkey 引起的extjs 布局混乱问题

最近测试反应系统在火狐18版本下偶尔会出现页面布局混乱的问题,出现频率还挺高,于是查了下,没有找到具体原因,不过开启firebug调试后,基本就不会出现问题了。在extjs论坛上看到已经有人发帖反应了,原因是由于18采用了最新的js编译引擎IonMonkey,他在编译extjs代码时有个bug导致的,

错误信息

引用
TypeError: callOverrideParent.caller is null
.../extjs/ext-all-dev.js Line: 37

具体原因是由于此段代码编译有问题
Ext.Base的callParent方法编译有问题,
解决方法1,覆写callParent方法,加入try catch块

if (Ext.firefoxVersion >= 18) {
    var noArgs = [];
    Ext.override(Ext.Base, {
        callParent : function(args) {


            var method, superMethod = (method = this.callParent.caller) &&
                    (method.$previous || ((method = method.$owner ?
                            method :
                            method.caller) && method.$owner.superclass[method.$name]));


            // Workarround for Firefox 18. I don't know why this works, but it does. Perhaps functions wich have 此处加入try catch后编译器将不再编译此方法
            // a try-catch block are handled differently
            try {} catch (e) {}
            return superMethod.apply(this, args || noArgs);
        }
    });
}

解决方法2:
firefox bug帖子上说18+的版本修复了这个bug,因此17号发布的18.0.1和19beta版应该都没有这个问题了,升级浏览器即可。

附加入try catch后问题解决的原因:
引用

The reason it's not reproducible is because it happens during some JIT compiling, so it's not really something we can "fix", since the symptom happens almost at random. The reason the try/catch works is because methods with try catch blocks don't get compiled.
The FF bug is here: https://bugzilla.mozilla.org/show_bug.cgi?id=818023


参考资料:
1.extjs问题帖子: http://www.sencha.com/forum/showthread.php?253345-FF-18-problem&s=4bf9757321c9fa4cb39a2ea4f7231662
2.firefox bug地址: https://bugzilla.mozilla.org/show_bug.cgi?id=818023

你可能感兴趣的:(JavaScript,Firebug,firefox 18.0.0,布局混乱)