对象不支持此操作 - 突然之间
Object doesn't support this action - all of a sudden
我是 运行 1.7.5 版,出于某些无法理解的原因,我突然遇到语法错误(none 我的样式表在工作后发生了变化)并且我以相同的方式包含 .js 文件):
Object doesn't support this action
我已将错误追溯到这个奇怪的片段(第 7880 行):
new(less.Parser)(env).parse(data, function (e, root) {
if (e) { return callback(e, null, null, sheet); }
try {
callback(e, root, data, sheet, webInfo, path);
} catch (e) {
callback(e, null, null, sheet);
}
}, {modifyVars: modifyVars, globalVars: less.globalVars});
...在 loadStyleSheet
函数中。事实上,我不明白该语法,并在控制台尝试它,我收到相同的错误消息:
new(less.Parser) # fails
new(less.Parser)(env) # fails
typeof less.Parser # yields "function"
这是怎么回事?
description: "Object doesn't support this action"
message: "Object doesn't support this action"
number: -2146827843
stack: "TypeError: Object doesn't support this action\n at Parser
(http://localhost:53109/Scripts/System/less-1.7.5.js:360:5)\n at
Anonymous function
(http://localhost:53109/Scripts/System/less-1.7.5.js:7880:13)\n at
Anonymous function
(http://localhost:53109/Scripts/System/less-1.7.5.js:7838:13)\n at
handleResponse
(http://localhost:53109/Scripts/System/less-1.7.5.js:7763:13)\n at
doXHR (http://localhost:53109/Scripts/System/less-1.7.5.js:7783:9)\n
at loadFile
(http://localhost:53109/Scripts/System/less-1.7.5.js:7832:5)\n at
loadStyleSheet
(http://localhost:53109/Scripts/System/less-1.7.5.js:7856:5)\n at
loadStyleSheets
(http://localhost:53109/Scripts/System/less-1.7.5.js:7896:9)\n at
less.refresh
(http://localhost:53109/Scripts/System/less-1.7.5.js:7973:5)\n at
Anonymous function
(http://localhost:53109/Scripts/System/less-1.7.5.js:7999:1)"
*更新我*
所以语法似乎没问题。我能做到:
new(function() {})('x')
所以考虑到 less.Parser
是一个代码应该工作的函数......但它没有。如果我查看 less.Parser
:
,这就是我得到的
function Parser(env) {
var input, // LeSS input string
i, // current index in `input`
j, // current chunk
saveStack = [], // holds state for backtracking
furthest, // furthest index the par
[Methods]: {...}
__proto__:
function() {
[native code]
}
arguments: null
caller: null
length: 1
prototype: {...}
有什么不对劲吗?
*更新二*
意识到 1.7.5 远远落后于当前版本,我升级到 2.5.0(立即离开 CDN)但现在它在其他地方中断(第 2440 行):
if (typeof Object.create === 'undefined') {
var F = function () {};
F.prototype = Error.prototype;
LessError.prototype = new F();
} else {
LessError.prototype = Object.create(Error.prototype); # breaks here
}
错误:
Object.create: argument is not an Object and is not null
如果我查看 Error.prototype
,我会得到 undefined
...grr...
经过一番哀嚎和咬牙切齿,我想通了。我的一个脚本正在设置:
var Error = {};
经验教训:小心你的变量名!如果编译器对此有所抱怨就好了。
我是 运行 1.7.5 版,出于某些无法理解的原因,我突然遇到语法错误(none 我的样式表在工作后发生了变化)并且我以相同的方式包含 .js 文件):
Object doesn't support this action
我已将错误追溯到这个奇怪的片段(第 7880 行):
new(less.Parser)(env).parse(data, function (e, root) {
if (e) { return callback(e, null, null, sheet); }
try {
callback(e, root, data, sheet, webInfo, path);
} catch (e) {
callback(e, null, null, sheet);
}
}, {modifyVars: modifyVars, globalVars: less.globalVars});
...在 loadStyleSheet
函数中。事实上,我不明白该语法,并在控制台尝试它,我收到相同的错误消息:
new(less.Parser) # fails
new(less.Parser)(env) # fails
typeof less.Parser # yields "function"
这是怎么回事?
description: "Object doesn't support this action" message: "Object doesn't support this action" number: -2146827843 stack: "TypeError: Object doesn't support this action\n at Parser (http://localhost:53109/Scripts/System/less-1.7.5.js:360:5)\n at Anonymous function (http://localhost:53109/Scripts/System/less-1.7.5.js:7880:13)\n at Anonymous function (http://localhost:53109/Scripts/System/less-1.7.5.js:7838:13)\n at handleResponse (http://localhost:53109/Scripts/System/less-1.7.5.js:7763:13)\n at doXHR (http://localhost:53109/Scripts/System/less-1.7.5.js:7783:9)\n
at loadFile (http://localhost:53109/Scripts/System/less-1.7.5.js:7832:5)\n at loadStyleSheet (http://localhost:53109/Scripts/System/less-1.7.5.js:7856:5)\n at loadStyleSheets (http://localhost:53109/Scripts/System/less-1.7.5.js:7896:9)\n at less.refresh (http://localhost:53109/Scripts/System/less-1.7.5.js:7973:5)\n at Anonymous function (http://localhost:53109/Scripts/System/less-1.7.5.js:7999:1)"
*更新我*
所以语法似乎没问题。我能做到:
new(function() {})('x')
所以考虑到 less.Parser
是一个代码应该工作的函数......但它没有。如果我查看 less.Parser
:
function Parser(env) {
var input, // LeSS input string
i, // current index in `input`
j, // current chunk
saveStack = [], // holds state for backtracking
furthest, // furthest index the par
[Methods]: {...}
__proto__:
function() {
[native code]
}
arguments: null
caller: null
length: 1
prototype: {...}
有什么不对劲吗?
*更新二*
意识到 1.7.5 远远落后于当前版本,我升级到 2.5.0(立即离开 CDN)但现在它在其他地方中断(第 2440 行):
if (typeof Object.create === 'undefined') {
var F = function () {};
F.prototype = Error.prototype;
LessError.prototype = new F();
} else {
LessError.prototype = Object.create(Error.prototype); # breaks here
}
错误:
Object.create: argument is not an Object and is not null
如果我查看 Error.prototype
,我会得到 undefined
...grr...
经过一番哀嚎和咬牙切齿,我想通了。我的一个脚本正在设置:
var Error = {};
经验教训:小心你的变量名!如果编译器对此有所抱怨就好了。