新手问题 rails 项目,production 模式在 ie8 下报"'undefined' 为空或不是对象"错误

gcywolf · May 19, 2017 · Last by fangxing204 replied at September 28, 2017 · 2615 hits

第一次发帖,还望社区的前辈不吝赐教

最近做一个 rails 项目的浏览器适配,出现了这样的问题: development 模式,一切正常 production 模式,压缩并预编译了 js,然后在 ie8 下就报 js 错误了,但在 chrome 下是正常的

去掉下面的 config.assets.js_compressor = :uglifier,ie8 下就没问题了

config.assets.compile = true

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass

以下是 jquery 源码,控制台中显示报错的位置在下面第一行,错误是'undefined' 为空或不是对象

// Ensure firing before onload, maybe late but safe also for iframes
    document.attachEvent( "onreadystatechange", completed );

    // A fallback to window.onload, that will always work
    window.attachEvent( "onload", completed );

    // If IE and not a frame
    // continually check to see if the document is ready
    var top = false;

    try {
        top = window.frameElement == null && document.documentElement;
    } catch ( e ) {}

困扰一天了,望大神解惑

看上去像 uglifier 压缩 js 时用了 ie8 不支持的语法,去看下 uglifier 的文档和 issue 呢,应该能找到些什么

同遇到这个问题,请问你解决了吗?搜索了好久未果...

决定把 uglifier 替换成 yui 了。

You need to Sign in before reply, if you don't have an account, please Sign up first.