当从HTML头加载图层时,IE9上的Dojo构建失败:属性'dir'未定义 [英] Dojo build fails on IE9 when loading layer from HTML header: property 'dir' is undefined

查看:124
本文介绍了当从HTML头加载图层时,IE9上的Dojo构建失败:属性'dir'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了一个dojo构建,但是我想要启用/禁用构建的灵活性,所以我试图加载到< script> 标签在HTML标题中:

I've made a dojo build, but I wanted the flexibility when enabling/disabling the build, so I've tried to load in in <script> tags in HTML header:

<script src="js/config.js"></script>
<script src="/dojo/1.9/dojo/dojo.js" data-dojo-config="async: true"></script>
<script src="/dojo/1.9/dojo/dojo-all.js"></script>

我没有修改我的JS文件。但似乎有一个问题,但只有在IE9上,只有部署在WebSphere上的应用程序版本(我已经在Apache2上测试过)。问题是,该属性dir未定义,在特定的代码片段中:

and I've left my JS file unmodified. It seems to function, however, there was a problem, but only on IE9, and only on application version deployed on WebSphere (I've tested on Apache2). The problem was, that property 'dir' was undefined, in that particular code fragment:

    geom.isBodyLtr = function isBodyLtr(doc) {
        doc = doc || win.doc;
        return (win.body(doc).dir || doc.documentElement.dir 
           || "ltr").toLowerCase() == "ltr";
    };

经过一些搜索类似的问题(例如:如何防止Unable获取属性dir的值:在IE9中加载页面时,对象为空或未定义错误),我检测到它可能是一些加载序列问题。我从HTML标题中删除了图层,并按照以下顺序将其加载到我的JS中:

After some searching for similar problems (such as this: How to prevent "Unable to get value of the property 'dir': object is null or undefined" error when loading pages in IE9), I've detected it can be some loading sequence problem. I've removed the layer from the HTML header, and loaded it in my JS in the following sequence:

require(["dojo/domReady!"], function(){
// load the layers, but only after document is ready
require(['dojo/dojo-all'], function(){

require(["dojo", "dojo/on", "dojo/dom-attr", "dojo/dom-class", (... and hundred more) 

然而,我知道人们正在HTML头文件中加载构建,例如从这里的主题: Dojo构建...现在?

However, I know that people are loading builds in HTML header, for example from topic here: Dojo Builds...? What now?

所以我的问题是,我做错了什么,或者HTML头的技巧不能保证在所有浏览器上都可以正常工作?

So my question is, am I doing something wrong, or that trick with HTML header is not guaranteed to work on all browsers?

这是我的构建脚本配置:

This is my build script config:

'dojo/dojo': {         
    include: ['dojo/dojo', 'dojo/domReady', 'dojo/_base/declare'],         
    boot: true,         
    customBase: true    
},
'dojo/dojo-all': {
    include: ["dojo/on", "dojo/dom-attr", "dojo/dom-class", "dojo/query", "dojo/_base/lang", "dojo/request/xhr", 
    "dijit/registry","dijit/form/TextBox", "dijit/form/Textarea", "dijit/form/ComboBox", "dijit/form/FilteringSelect", "dijit/form/CheckBox", "dijit/form/Button",
    "gridx/core/model/cache/Sync", "gridx/Grid", "gridx/modules/SingleSort", "gridx/modules/ColumnResizer", 
    (...and hundred more)],
    boot: false, // exclude bootstrap modules
    customBase: false
},

这是来自dojo的build.bat:

and this is the build.bat from dojo:

java -Xms256m -Xmx256m  -cp "%~dp0../shrinksafe/js.jar";"%
~dp0../closureCompiler/compiler.jar";"%~dp0../shrinksafe/shrinksafe.jar" 
org.mozilla.javascript.tools.shell.Main  "%~dp0../../dojo/dojo.js" 
baseUrl="%~dp0../../dojo" load=build %*


推荐答案

我们最近遇到了与图层文件加载顺序相同的问题。为了使它与IE9一起工作,您真的需要控制层文件加载的顺序,所以是的,最简单和最可靠的方法是要求您的图层文件比使用< script> 加载它们。

We've recently had the same sort of problem with the order of layer files loading. To get it working with IE9, you really need to take control over the order of layer file loading, so yes, the simplest and most reliable approach is to require your layer files rather than using <script> to load them.

查看此页面底部的示例,其中包含一个需要嵌套在另一个需求中:

Check out the sample at the bottom of this page which contains a require nested inside another require:

http://www.sitepen.com/blog/2012/06/11/dgrid-and-dojo-nano-build/

我们刚刚在产品中做了完全相同的更改,以避免IE9和IE10出现零星故障(7层文件,其中一个需要覆盖旧版本的模块定义其中一个)。 < script >似乎似乎已经正常工作了一段时间,但事实证明,我们不能依靠它。

We've just made exactly the same changes in a product here to avoid sporadic failures with IE9 and IE10 (with 7 layer files, one of which needed to override an older version of a module defined in one of the others). <script> had seemingly worked fine for some time, but it turned out that we couldn't rely on it.

这篇关于当从HTML头加载图层时,IE9上的Dojo构建失败:属性'dir'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆