Homeland CURRENT_USER_ACCESS_TOKEN is not defined issues/218 的修复感觉不对吧?

lihuazhang · 2013年10月21日 · 最后由 huacnlee 回复于 2013年10月21日 · 4087 次阅读

https://github.com/ruby-china/ruby-china/issues/218

CURRENT_USER_ACCESS_TOKEN = "xxxxx" // 全局变量,的确在window里。
return unless ('CURRENT_USER_ACCESS_TOKEN' in window)

in 被翻译成了

var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

'CURRENT_USER_ACCESS_TOKEN' in window 永远返回是 false。faye client 就没法初始化了。

求解!

You can use “in” to test for array presence,and "of" to test for JS object-key presence

这里 in 明显用错的

需要 登录 后方可回复, 如果你还没有账号请 注册新账号