0

ag-grid を実装したばかりですが、内部でコンパイルされた角度のあるテンプレートで cellTemplates を使用すると IE9 がクラッシュすることがわかりました。

これに遭遇し、回避策を見つけた人はいますか?

再現方法:

ここ ( http://www.ag-grid.com/angular-grid-cell-template/index.php ) に IE でアクセスし、DevTools から IE9 を選択します。

angular コンパイルされたテンプレートが原因でクラッシュします。私がそれについて何ができるかわからない。

(これについても GitHub で問題を開きました: https://github.com/ceolter/ag-grid/issues/521 )

編集:

それをデバッグすると、あるメソッドからの配列への更新が何らかの形で別のメソッドに表示されないため、無限ループが発生します...

無限ループは次のとおりです: getTemplate、(呼び出しが終了するまで待機)、呼び出しの終了、テンプレートのキャッシュへの追加、コールバックの実行、コールバックは templateCache 内のテンプレートを参照せず、別のコールバックの作成、キューへの追加などの上。(以下の ag-grid のコード)。

// returns the template if it is loaded, or null if it is not loaded
        // but will call the callback when it is loaded
        TemplateService.prototype.getTemplate = function (url, callback) {
            var templateFromCache = this.templateCache[url];
            if (templateFromCache) {
                return templateFromCache;
            }
            var callbackList = this.waitingCallbacks[url];
            var that = this;
            if (!callbackList) {
                // first time this was called, so need a new list for callbacks
                callbackList = [];
                this.waitingCallbacks[url] = callbackList;
                // and also need to do the http request
                var client = new XMLHttpRequest();
                client.onload = function () {
                    that.handleHttpResult(this, url);
                };
                client.open("GET", url);
                client.send();
            }
            // add this callback
            if (callback) {
                callbackList.push(callback);
            }
            // caller needs to wait for template to load, so return null
            return null;
        };
        TemplateService.prototype.handleHttpResult = function (httpResult, url) {
            if (httpResult.status !== 200 || httpResult.response === null) {
                console.warn('Unable to get template error ' + httpResult.status + ' - ' + url);
                return;
            }
            // response success, so process it
            this.templateCache[url] = httpResult.response;
            // inform all listeners that this is now in the cache
            var callbacks = this.waitingCallbacks[url];
            for (var i = 0; i < callbacks.length; i++) {
                var callback = callbacks[i];
                // we could pass the callback the response, however we know the client of this code
                // is the cell renderer, and it passes the 'cellRefresh' method in as the callback
                // which doesn't take any parameters.
                callback();
            }
            if (this.$scope) {
                var that = this;
                setTimeout(function () {
                    that.$scope.$apply();
                }, 0);
            }
        };
        return TemplateService;
    })();
4

1 に答える 1

1

私は最終的に問題を見つけました。IE9 では、テンプレートは応答内の responseText にあります。IE10+ および他のすべてのブラウザーでは、応答しています。

したがって、それを修正するには、上記のコードで次の代わりに:

     // response success, so process it
     this.templateCache[url] = httpResult.response;

追加した:

     // response success, so process it
     //in IE9 the response is in - responseText
     this.templateCache[url] = httpResult.response || httpResult.responseText;

今後の参考のために、ここに回答を追加してください。Angularとは何の関係もありませんでした。:)

更新: https://github.com/ceolter/ag-grid/issues/521

コードがレポに入りました :) Niall Crosby (ceolter) に感謝します。

于 2015-10-23T09:30:28.040 に答える