IE10 Extjs 4.1.0 insertSibling无法正常工作

时间:2014-12-12 15:54:40

标签: javascript extjs extjs4

我有以下代码:

        var messageWrapper = {
            tag: 'div'
        };

        var messageEl = cmp.errorEl.insertSibling(messageWrapper, "after");
        cmp.messageEl = messageEl;

        Ext.Array.each(me.displayProperties, function (property) {
            var propertyConfig = {
                tag: 'div',
                style: {
                    display: 'none'
                }
            };
            var newElement = messageEl.insertSibling(propertyConfig, "after");
            newElement.addCls(property.classes);

            var changeListener = me.buildChangeListener(newElement, property.name);
            cmp.addListener('change', changeListener);
        });

以前在ExtJs 4.0.7下运行正常,但在chrome下仍能正常工作。

问题是 cmp.errorEl.insertSibling(messageWrapper,“after”)在IE下返回null,我可以添加额外的true参数 - 然后我会收到dom对象,但我不会能够使用extjs功能。

你知道我该怎么办吗?

小提琴可在以下网址找到:https://fiddle.sencha.com/#fiddle/f1a

1 个答案:

答案 0 :(得分:3)

ExtJS 4.1.0框架的Ext.dom.Helper(ietable方法)中存在一个错误。 应用此覆盖来修复它:

(function() {

// kill repeat to save bytes
var detachedDiv = document.createElement('div');

    Ext.define('Ext.override.dom.Helper', {
        override: 'Ext.dom.AbstractHelper',

        ieTable: function(depth, openingTags, htmlContent, closingTags){
            detachedDiv.innerHTML = [openingTags, htmlContent, closingTags].join('');

            var i = -1,
                el = detachedDiv,
                ns;
            while (++i < depth) {
                el = el.firstChild;
            }
            // If the result is multiple siblings, then encapsulate them into one fragment.
            ns = el.nextSibling;

            if (ns) {
                el = document.createDocumentFragment();
                while (ns) {
                    el.appendChild(ns);
                    ns = ns.nextSibling;
                }
            }
            return el;
        }

    }, function() {
        Ext.ns('Ext.core');
        Ext.DomHelper = Ext.core.DomHelper = new this;
    });

}());

小提琴:https://fiddle.sencha.com/#fiddle/f1v