Javascript 替换不推荐的dijit/_Widget.getDescents函数?

Javascript 替换不推荐的dijit/_Widget.getDescents函数?,javascript,dojo,Javascript,Dojo,我使用的是Dojo1.9.1和lodash.compat 1.3.1 我正在尝试替换不推荐使用的函数。弃用警告表示改为使用getChildren(),但这不会再次出现 这就是我目前所拥有的。它在Chrome和Firefox中运行良好,但在IE7中会导致一个毫无帮助的[对象错误] function get_widget_descendants(parent_widget) { return _(query("[widgetid]", parent_widget.domNode))

我使用的是Dojo1.9.1和lodash.compat 1.3.1

我正在尝试替换不推荐使用的函数。弃用警告表示改为使用
getChildren()
,但这不会再次出现

这就是我目前所拥有的。它在Chrome和Firefox中运行良好,但在IE7中会导致一个毫无帮助的
[对象错误]

function get_widget_descendants(parent_widget) {
    return _(query("[widgetid]", parent_widget.domNode))
    .map(registry.byNode)
    .value();
}
下面是一个演示它应该如何工作的例子(我认为JSFIDLE本身在IE7中不起作用,实际上它确实起作用,请参见)

更新:实际上,lodash本身并没有通过IE7。没关系,lodash.compat构建确实如此。然而,compat构建仍然存在同样的问题


有人知道如何在IE7下工作吗?有人已经解决了这个问题吗?

根据您的小提琴,看起来您正在寻找作为小部件子部件的表单小部件

dojox/form/Manager
有一个名为
inspectFormWidgets
的方法,它可以完成您正在查找的内容

dijit/form/FormMixin
有一个可以重用的方法:

_getDescendantFormWidgets: function(/*dijit/_WidgetBase[]?*/ children){
    var res = [];
    array.forEach(children || this.getChildren(), function(child){
        if("value" in child){
            res.push(child);
        }else{
            res = res.concat(this._getDescendantFormWidgets(child.getChildren()));
        }
    }, this);
    return res;
},
您可以使用以下命令调用它

require(['dijit/form/_FormMixin'], function(DijitFormMixin) {

    var widget = ...

    var descendants = DijitFormMixin.prototype._getDescendantFormWidgets.call(
        widget, widget.getChildren());
});
如果您需要获得的不仅仅是表单小部件,您可以创建一个类似于
\u getDegenantFormWidgets
的函数