javascript Ember.js 1.10 - 无法在 'Element' 上执行 'setAttribute':'"' 不是有效的属性名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28400797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ember.js 1.10 - Failed to execute 'setAttribute' on 'Element': '"' is not a valid attribute name
提问by Alexey Temnikov
After upgrading from Ember.js 1.9 to 1.10 I got following error -
从 Ember.js 1.9 升级到 1.10 后,出现以下错误 -
Uncaught InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '"' is not a valid attribute name.
未捕获的 InvalidCharacterError:无法在 'Element' 上执行 'setAttribute':'"' 不是有效的属性名称。
prototype.setAttribute = function(element, name, value) {
element.setAttribute(name, String(value));
};
Values are:
值是:
value: ""
name: """
element: <span></span>
What is easiest way to find what issue might be with the upgrade and what should be fixed? The error is not very user friendly.
找出升级可能存在的问题以及应该修复哪些问题的最简单方法是什么?该错误对用户不是很友好。
回答by Alexey Temnikov
Steps to troubleshoot:
故障排除步骤:
- Open compiled template (in my case it was in stacktrace VM.js:XXXX).
- Read it carefully.
- 打开编译模板(在我的例子中是在 stacktrace VM.js:XXXX 中)。
- 仔细阅读。
In my case it contained
就我而言,它包含
var el1 = dom.createElement("span");
dom.setAttribute(el1,"\"","");
dom.appendChild(el0, el1);
- Open source template that corresponds these lines.
- 对应这些行的开源模板。
e.g.
例如
<span {{action "setUrgency" urgentItem.urgency}} {{bind-attr class=urgentItem.styleClass}}"></span>
- Remove ' (this was an issue).
- 删除 '(这是一个问题)。
This issue was caused by incorrect template (HTMLBars was able to compile it without warnings) however error occured during executing the compiled template. Once template is fixed, everything is working fine.
这个问题是由错误的模板引起的(HTMLBars 能够在没有警告的情况下编译它)但是在执行编译的模板期间发生错误。一旦模板固定,一切正常。