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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 08:55:30  来源:igfitidea点击:

Ember.js 1.10 - Failed to execute 'setAttribute' on 'Element': '"' is not a valid attribute name

javascriptember.js

提问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:

故障排除步骤:

  1. Open compiled template (in my case it was in stacktrace VM.js:XXXX).
  2. Read it carefully.
  1. 打开编译模板(在我的例子中是在 stacktrace VM.js:XXXX 中)。
  2. 仔细阅读。

In my case it contained

就我而言,它包含

var el1 = dom.createElement("span");
dom.setAttribute(el1,"\"","");
dom.appendChild(el0, el1);
  1. Open source template that corresponds these lines.
  1. 对应这些行的开源模板。

e.g.

例如

<span {{action "setUrgency" urgentItem.urgency}} {{bind-attr class=urgentItem.styleClass}}"></span>
  1. Remove ' (this was an issue).
  1. 删除 '(这是一个问题)。

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 能够在没有警告的情况下编译它)但是在执行编译的模板期间发生错误。一旦模板固定,一切正常。