以下错误仅发生在IE8
... Chrome
和Firefox
中的工作无法测试IE9,因为我最近因测试目的而降级。
意外调用方法或属性访问。
标有 \\电话的相关代码在此处
来自IE Debugger的调试值......:
_frames =对象/功能
callback = object / function
callbackTarget = object / function
callbackArg = undefined
ko.dependencyDetection = (function () {
var _frames = [];
return {
begin: function (callback) {
_frames.push({ callback: callback, distinctDependencies:[] });
},
end: function () {
_frames.pop();
},
registerDependency: function (subscribable) {
if (!ko.isSubscribable(subscribable))
throw new Error("Only subscribable things can act as dependencies");
if (_frames.length > 0) {
var topFrame = _frames[_frames.length - 1];
if (!topFrame || ko.utils.arrayIndexOf(topFrame.distinctDependencies, subscribable) >= 0)
return;
topFrame.distinctDependencies.push(subscribable);
topFrame.callback(subscribable);
}
},
ignore: function(callback, callbackTarget, callbackArgs) {
try {
_frames.push(null);
return callback.apply(callbackTarget, callbackArgs || []);
}
//Call occurs here
//Error occurs here since there isn't a catch and the try is failing.
finally {
_frames.pop();
}
}
};
})();
来自:
"notifySubscribers": function (valueToNotify, event) {
event = event || defaultEvent;
if (this._subscriptions[event]) {
//Call occurs here
ko.dependencyDetection.ignore(function() {
ko.utils.arrayForEach(this._subscriptions[event].slice(0), function (subscription) {
// In case a subscription was disposed during the arrayForEach cycle, check
// for isDisposed on each subscription before invoking its callback
if (subscription && (subscription.isDisposed !== true))
subscription.callback(valueToNotify);
});
}, this);
}
},
来自:
ko.observable = function (initialValue) {
var _latestValue = initialValue;
function observable() {
if (arguments.length > 0) {
// Write
// Ignore writes if the value hasn't changed
if ((!observable['equalityComparer']) || !observable['equalityComparer'](_latestValue, arguments[0])) {
observable.valueWillMutate();
_latestValue = arguments[0];
if (DEBUG) observable._latestValue = _latestValue;
observable.valueHasMutated();
}
return this; // Permits chained assignments
}
else {
// Read
ko.dependencyDetection.registerDependency(observable); // The caller only needs to be notified of changes if they did a "read" operation
return _latestValue;
}
}
if (DEBUG) observable._latestValue = _latestValue;
ko.subscribable.call(observable);
observable.peek = function() { return _latestValue };
//call occurs here
observable.valueHasMutated = function () { observable["notifySubscribers"](_latestValue); }
observable.valueWillMutate = function () { observable["notifySubscribers"](_latestValue, "beforeChange"); }
ko.utils.extend(observable, ko.observable['fn']);
ko.exportProperty(observable, 'peek', observable.peek);
ko.exportProperty(observable, "valueHasMutated", observable.valueHasMutated);
ko.exportProperty(observable, "valueWillMutate", observable.valueWillMutate);
return observable;
}
来自:
ko.observable = function (initialValue) {
var _latestValue = initialValue;
function observable() {
if (arguments.length > 0) {
// Write
// Ignore writes if the value hasn't changed
if ((!observable['equalityComparer']) || !observable['equalityComparer'](_latestValue, arguments[0])) {
observable.valueWillMutate();
_latestValue = arguments[0];
if (DEBUG) observable._latestValue = _latestValue;
//Call occurs here
observable.valueHasMutated();
}
return this; // Permits chained assignments
}
else {
// Read
ko.dependencyDetection.registerDependency(observable); // The caller only needs to be notified of changes if they did a "read" operation
return _latestValue;
}
}
if (DEBUG) observable._latestValue = _latestValue;
ko.subscribable.call(observable);
observable.peek = function() { return _latestValue };
observable.valueHasMutated = function () { observable["notifySubscribers"](_latestValue); }
observable.valueWillMutate = function () { observable["notifySubscribers"](_latestValue, "beforeChange"); }
ko.utils.extend(observable, ko.observable['fn']);
ko.exportProperty(observable, 'peek', observable.peek);
ko.exportProperty(observable, "valueHasMutated", observable.valueHasMutated);
ko.exportProperty(observable, "valueWillMutate", observable.valueWillMutate);
return observable;
}
来自:
self.fraudQueue(msg.d);
视图模型
function FraudQueueViewModel(runDate, analyst, fraudOid, runNumber, processed, parameter) {
var self = this;
self.fraudQueue = ko.observableArray();
\\...
msg.d
无法分享真实的msg.d
,但已经过有效JSON
和JS object
验证,并且是array
。
错误似乎位于msg.d
的内部数组中... msg.d
包含18个内部arrays
objects
,其中一些包含另一个内部array
}。
答案 0 :(得分:5)
在我的具体情况下,问题是“简单” ...在使用IE9作为IE8运行6小时以上的调试之后我将domNode
添加到监视列表中,并看到它未能appendChild
...我看着dom元素,它是:
<td data-bind="text: viewModel.functionName(property)"></td>
我所做的就是将此绑定更改为以下内容:
<td>
<span data-bind="text: viewModel.functionName(property)"></span>
</td>
显然IE8在双嵌套function
循环中绑定text
foreach
元素时遇到问题。我不确定这是否能帮助其他人,但重要的是在IE8模式下使用IE9调试问题。这允许您使用Add to watch
,它允许您查看对象的属性...然后查找它失败的节点,猜测和祈祷。
上帝速度......
答案 1 :(得分:1)
通过类似于abc123的情况经验,在IE8中,您使用的任何HTML5元素都不能绑定文本元素。对于许多元素,我不得不用一个好的旧div / span标记替换html5标记,因为它不会绑定到“text”。