【发布时间】:2014-08-16 20:25:52
【问题描述】:
更新:问题不在于火花 - 尽管我误解了正在发生的事情,因此问题的形成有些不正确,但我将这个问题留在了以防万一它有利于其他人。
我收到以下错误:
Exception from Deps recompute: TypeError: Cannot read property 'nodeName' of null
at Patcher.match (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1540:12)
当我点击第二行的链接时,它会将我引导到 spark.js 的以下部分,其中错误是:
// Look at tags of parents until we hit parent of last-kept, // 229
// which we know is ok. // 230
for(var a=tgt.parentNode, b=src.parentNode; // 231
a !== (starting ? this.tgtParent : lastKeptTgt.parentNode); // 232
a = a.parentNode, b = b.parentNode) { // 233
if (b === (starting ? this.srcParent : lastKeptSrc.parentNode)) // 234
return false; // src is shallower, b hit top first // 235
if (a.nodeName !== b.nodeName) // 236
return false; // tag names don't match // 237
}
违规行是这一行:if (a.nodeName !== b.nodeName)。我想调试这个...如何修改 spark.js 文件?我想像console.log(a)一样输入语句,并想检查a或b是否具有属性nodeName。
StackOverflow 上与此相关的问题是:
How to investigate "Exception form Deps recompute" what are the clues?
How can I modify the Meteor (meteorite) that is running?
第一个没有真正回答。第二个包括有关如何将包添加到流星以便您可以修改它的建议。但这对我不起作用 - 我的修改要么没有显示(如果我遵循上面链接 #2 中的建议),要么生成了一个错误,说流星找不到 spark.js(如果我试图修改 spark在 ~/.meteor/ 或我的项目的 .meteor/ 目录中的包文件夹的客户端文件夹中的 .js 文件。
有人对我如何修改我的流星项目的 spark.js 文件(客户端版本)有任何建议吗?
谢谢!
2013 年 11 月 9 日更新:
我收到这些错误的原因是因为我试图将异步调用谷歌地图 geocoder.geocode() 对象/方法的结果存储在反应会话变量中:
SessionAmplify = _.extend({}, Session, {
keys: _.object(_.map(amplify.store(), function(value, key) {
return [key, JSON.stringify(value)]
})),
set: function (key, value) {
Session.set.apply(this, arguments);
amplify.store(key, value);
},
});
setLocation = function (e) {
e.preventDefault;
var address = e.target.value;
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
$('.found-address').html(results[0].formatted_address);
SessionAmplify.set('pos', results[0].geometry.location);
SessionAmplify.set('formatted_address', results[0].formatted_address);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
return true;
};
问题行是SessionAmplify.set('pos', results[0].geometry.location); 和SessionAmplify.set('formatted_address', results[0].formatted_address);。似乎results 变量没有及时到达让我设置会话变量-这很奇怪,因为除非status 变量到达,否则该代码块不应运行,我认为它应该与@ 同时到达987654337@变量。
我研究过使用Meteor._wrapAsync()(我观看了eventedmind 教程:https://www.eventedmind.com/feed/Ww3rQrHJo8FLgK7FF),但我不知道如何将Meteor._wrapAsync() 与geocoder.geocode() 一起使用。一个问题是Meteor._wrapAsync() 要求回调函数具有形式函数(错误,结果),但地理编码回调的函数具有形式function(result, status)。有什么建议吗?
【问题讨论】:
-
meteorpedia.com/read/…这个链接可能有帮助
标签: meteor