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

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

问题描述

我已经创建了一个 dojo 构建,但我希望在启用/禁用构建时具有灵活性,因此我尝试在 HTML 标头中的 <script> 标签中加载:

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";
    };

经过一些类似问题的搜索(例如:如何防止在 IE9 中加载页面时出现无法获取属性 'dir' 的值:对象为空或未定义"错误),我检测到它可能是一些加载顺序问题.我已经从 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 标头中加载构建,例如来自这里的主题:道场建造……?现在怎么办?

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 一起工作,你真的需要控制层文件加载的顺序,所以是的,最简单和最可靠的方法是 require 你的层文件而不是使用 <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.

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

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 层文件,其中一个需要覆盖其他一个中定义的模块的旧版本)的偶发故障.> 表面上运行了一段时间,但结果证明我们不能依赖它.

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 标头加载图层时,Dojo 构建在 IE9 上失败:未定义属性“dir"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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