我的网页引发了一个javascript错误,但我无法弄清楚原因。我正在尝试调试导入到客户端网站的脚本。它在这里抛出错误:
function(t){
e._trigger("receive",t,this._uiHash(this))
}
错误是" Uncaught SyntaxError:意外的令牌("
对于上下文,这里是它所在的代码块。不幸的是,我不知道这些函数的用途是什么,但错误是阻止页面正确加载。希望这个Javascript足以提供上下文,完整的脚本很长。
_clear: function(e, t) {
this.reverting = !1;
var i, n = [];
if (!this._noFinalSort && this.currentItem.parent().length && this.placeholder
.before(this.currentItem), this._noFinalSort = null, this.helper[0] ===
this.currentItem[0]) {
for (i in this._storedCSS)
("auto" === this._storedCSS[i] || "static" === this._storedCSS[
i]) && (this._storedCSS[i] = "");
this.currentItem.css(this._storedCSS).removeClass(
"ui-sortable-helper")
} else this.currentItem.show();
for (this.fromOutside && !t && n.push(function(e) {
this._trigger("receive", e, this._uiHash(this.fromOutside))
}), !this.fromOutside && this.domPosition.prev === this.currentItem
.prev().not(".ui-sortable-helper")[0] && this.domPosition.parent ===
this.currentItem.parent()[0] || t || n.push(function(e) {
this._trigger("update", e, this._uiHash())
}), this !== this.currentContainer && (t || (n.push(function(e) {
this._trigger("remove", e, this._uiHash())
}), n.push(function(e) {
return
function(t) {
e._trigger("receive", t, this._uiHash(this))
}
}.call(this, this.currentContainer)), n.push(function(e) {
return
function(t) {
e._trigger("update", t, this._uiHash(this))
}
}.call(this, this.currentContainer)))), i = this.containers.length -
1; i >= 0; i--) t || n.push(function(e) {
return function(t) {
e._trigger("deactivate", t, this._uiHash(this))
}
}.call(this, this.containers[i])), this.containers[i].containerCache
.over && (n.push(function(e) {
return
function(t) {
e._trigger("out", t, this._uiHash(this))
}
}.call(this, this.containers[i])), this.containers[i].containerCache
.over = 0);
if (this.storedCursor && (this.document.find("body").css("cursor", this
.storedCursor), this.storedStylesheet.remove()), this._storedOpacity &&
this.helper.css("opacity", this._storedOpacity), this._storedZIndex &&
this.helper.css("zIndex", "auto" === this._storedZIndex ? "" : this
._storedZIndex), this.dragging = !1, this.cancelHelperRemoval) {
if (!t) {
for (this._trigger("beforeStop", e, this._uiHash()), i = 0; n.length >
i; i++) n[i].call(this, e);
this._trigger("stop", e, this._uiHash())
}
return this.fromOutside = !1, !1
}
if (t || this._trigger("beforeStop", e, this._uiHash()), this.placeholder[
0].parentNode.removeChild(this.placeholder[0]), this.helper[0] !==
this.currentItem[0] && this.helper.remove(), this.helper = null, !t
) {
for (i = 0; n.length > i; i++) n[i].call(this, e);
this._trigger("stop", e, this._uiHash())
}
return this.fromOutside = !1, !0
}
如果您想查看该页面,请找到here
答案 0 :(得分:5)
代码的每个部分如下所示:
return
function(t) {
e._trigger("out", t, this._uiHash(this))
}
坏了。 JavaScript自动分号插入的规则是这样的,当解析器命中换行符时,那些return
语句被视为完整。它必须看起来像:
return function(t) {
e._trigger("out", t, this._uiHash(this))
}
这看起来令人惊讶,但这是真的。您正在获得的错误是因为解析器认为function
关键字正在打开一个新的函数声明语句,并且在这样的语句中,函数名称不是可选的。