2014-01-08 33 views
0

我正在开发一个使用大量js库并主要使用Express JS的应用程序。 所有代码在Firefox和Chrome中都可以正常工作。但我在IE8和IE9中遇到错误。只在IE8和IE9中发生错误,而不在其他浏览器中

SCRIPT5022: fromText eval for hbs!notification/templates/dropDown failed: SyntaxError: Syntax error in regular expression 
http://requirejs.org/docs/errors.html#fromtexteval 
require.js, line 138 character 9 

SCRIPT5022: fromText eval for hbs!notification/templates/dropDownItem failed: SyntaxError: Syntax error in regular expression 
http://requirejs.org/docs/errors.html#fromtexteval 
require.js, line 138 character 9 

SCRIPT5022: fromText eval for hbs!layouts/admin/templates/teamManagement failed: SyntaxError: Syntax error in regular expression 
http://requirejs.org/docs/errors.html#fromtexteval 
require.js, line 138 character 9 

SCRIPT5022: fromText eval for hbs!layouts/admin/alarms/templates/projectAlarms failed: SyntaxError: Syntax error in regular expression 
http://requirejs.org/docs/errors.html#fromtexteval 
require.js, line 138 character 9 

SCRIPT5022: fromText eval for hbs!admin/templates/navigation failed: SyntaxError: Syntax error in regular expression 
http://requirejs.org/docs/errors.html#fromtexteval 
require.js, line 138 character 9 

SCRIPT5022: fromText eval for hbs!layouts/admin/templates/base failed: SyntaxError: Syntax error in regular expression 
http://requirejs.org/docs/errors.html#fromtexteval 
require.js, line 138 character 9 

这些错误只出现在IE8和IE9中。

这里是我的config.js

require.config({ 
    paths: { 
    // Require plugins 
    'text': 'vendor/requirejs-text/text', 
    'css': 'vendor/css/css', 
    'hbs': 'vendor/require-handlebars-plugin/hbs', 
    'Handlebars': 'vendor/require-handlebars-plugin/Handlebars', 
    'i18nprecompile': 'vendor/require-handlebars-plugin/i18nprecompile', 
    'json2': 'vendor/require-handlebars-plugin/json2', 

    // Libraries 
    'es5shim': 'vendor/es5-shim/es5-shim', 
    'underscore': 'vendor/underscore/underscore', 
    'jquery': 'vendor/jquery/jquery', 
    'jquery.DatePicker': 'vendor/datepicker/datepicker', 
    'jquery.mousewheel': 'vendor/jquery-mousewheel/jquery.mousewheel', 
    'backbone': 'vendor/backbone/backbone', 
    'backbone.virtualCollection': 'vendor/backbone-virtual-collection/backbone.virtual-collection', 
    'backbone.marionette': 'vendor/backbone.marionette/backbone.marionette', 
    'backbone.marionette.handlebars': 'vendor/backbone.marionette.handlebars/backbone.marionette.handlebars', 
    'leaflet': 'vendor/leaflet/leaflet-src', 
    'highcharts': 'vendor/highcharts/highcharts.src', 
    'paper': 'vendor/paper/paper', 
    'handsontable': 'vendor/handsontable/jquery.handsontable', 
    'walltime': 'vendor/walltime-js/walltime', 
    'walltime-data': 'vendor/walltime-js/walltime-data' 
    }, 
    shim: { 
    'underscore': { 
     exports: '_' 
    }, 
    'jquery.DatePicker': { 
     deps: ['jquery'] 
    }, 
    'backbone': { 
     deps: ['underscore', 'jquery'], 
     exports: 'Backbone' 
    }, 
    'backbone.marionette': { 
     deps: ['backbone'], 
     exports: 'Marionette' 
    }, 
    'backbone.virtualCollection': { 
     deps: ['backbone', 'underscore'] 
    }, 
    'leaflet': { 
     exports: 'L' 
    }, 
    'highcharts': { 
     deps: ['jquery'], 
     exports: 'Highcharts' 
    }, 
    'walltime': { 
     deps: ['walltime-data'] 
    } 
    }, 
    hbs: { 
    i18nDirectory: 'i18n/', 
    disableI18n: false,  // This disables the i18n helper and 
           // doesn't require the json i18n files (e.g. en_us.json) 
           // (false by default) 

    disableHelpers: true,  // When true, won't look for and try to automatically load 
           // helpers (false by default) 

    helperPathCallback:  // Callback to determine the path to look for helpers 
     function (name) {  // ('/template/helpers/'+name by default) 
     return 'cs!' + name; 
     }, 

    compileOptions: {}  // options object which is passed to Handlebars compiler 
    } 
}); 

请帮我家伙!

----- 更新 -----

我在Github上发布这是问题的requirejs回购。
你可以找到它here
根据评论,它似乎是问题是在IE9 eval
我也试图把eval("("+text+")")作为here,但仍然没有奏效。

任何人都可以请告诉我如何得到这个eval事情在IE9中工作。

感谢

+0

尝试在你的html中添加这个 Dalorzo

+0

http://stackoverflow.com/questions/5802461/javascript-which-browsers-support-解析的ISO-8601日期字符串与日期标准杆 – Dalorzo

+0

@Dororzo:第一评论没有奏效! – Pratik

回答

0

这似乎有类似的问题,在JQuery的

发生的这一切都是在DOM没有准备好,并且由于DOM没有完全加载出现此错误有关。

如果你还没有这么做过尝试在年底页面或某种延迟加载的添加脚本:

http://www.joezimjs.com/javascript/lazy-loading-javascript-with-requirejs/ 如何使用RequireJS实现延迟加载? 顺便说在这方面只交看来微软拒绝它不认为这是一个错误:

https://connect.microsoft.com/IE/feedback/details/792880/document-readystat

3

这是我的问题,可能你:

//IE with conditional comments on cannot handle the 
//sourceURL trick, so skip it if enabled. 
/*@if (@_jscript) @else @*/ 
if (!config.isBuild) { 
    text += "\r\n//@ sourceURL=" + path; 
} 
/*@[email protected]*/ 

IE会吹了如果源URL位于传递给eval的文本的末尾,则会出现语法错误。

1

@jsfellow的回答真的很有帮助! 显示的片段位于require-handlebars-plugin的hbs.js中。 按照sourcemap proposal

//# sourceURL= 

优于

//@ sourceURL= 

后我在hbs.js改变相应的行,一切都按预期在所有测试的浏览器(谷歌浏览器35,火狐30, IE 8-10)。 我在require-handlebars-plugin github repo提交了一个拉取请求,该请求目前已合并和评估。

我希望这可以帮助任何人遇到相同的问题。

相关问题