{"id":401,"date":"2015-11-06T10:10:00","date_gmt":"2015-11-06T10:10:00","guid":{"rendered":"http:\/\/www.corrspt.com\/blog\/?p=401"},"modified":"2015-11-06T10:10:00","modified_gmt":"2015-11-06T10:10:00","slug":"emberjs-failed-to-execute-setattribute-on-element-is-not-a-valid-attribute-name","status":"publish","type":"post","link":"http:\/\/www.corrspt.com\/blog\/2015\/11\/06\/emberjs-failed-to-execute-setattribute-on-element-is-not-a-valid-attribute-name\/","title":{"rendered":"EmberJS &#8211; Failed to execute &#8216;setAttribute&#8217; on &#8216;Element&#8217;: &#8216;=&#8217; is not a valid attribute name."},"content":{"rendered":"<p>Hi<\/p>\n<p>Just wanted to do a quick post about this error I got when developing an <a href=\"http:\/\/www.emberjs.com\" target=\"_blank\">EmberJS <\/a>Application and trying to test a component (via an Integration test). The following error occurred while running the test:<\/p>\n<pre>Error: Failed to execute 'setAttribute' on 'Element': '=' is not a valid attribute name.\r\n    at Error (native)\r\n    at DOMHelper.prototype.setAttribute (http:\/\/localhost:4200\/assets\/vendor.js:12027:13)\r\n    at Object.buildFragment (http:\/\/localhost:4200\/assets\/weldnote.js:24465:13)\r\n    at getCachedFragment (http:\/\/localhost:4200\/assets\/vendor.js:55321:29)\r\n    at Function.RenderResult.build (http:\/\/localhost:4200\/assets\/vendor.js:55044:20)\r\n    at render (http:\/\/localhost:4200\/assets\/vendor.js:55008:37)\r\n    at http:\/\/localhost:4200\/assets\/vendor.js:55799:11\r\n    at renderAndCleanup (http:\/\/localhost:4200\/assets\/vendor.js:55836:18)\r\n    at Object.block [as default] (http:\/\/localhost:4200\/assets\/vendor.js:55797:9)\r\n    at keywords.yield (http:\/\/localhost:4200\/assets\/vendor.js:54620:25)<\/pre>\n<p>I was trying to create an integration test for a component like the following (the default generated test, where I removed the block form assertion):<\/p>\n<pre>import { moduleForComponent, test } from 'ember-qunit';\r\nimport hbs from 'htmlbars-inline-precompile';\r\n\r\nmoduleForComponent('\/w-powerselect', 'Integration | Component | w powerselect', {\r\n  integration: true\r\n});\r\n\r\ntest('it renders', function(assert) {\r\n  assert.expect(1);\r\n\r\n  \/\/ Set any properties with this.set('myProperty', 'value');\r\n  \/\/ Handle any actions with this.on('myAction', function(val) { ... });\r\n\r\n  this.render(hbs`{{w-powerselect}}`);\r\n\r\n  assert.equal(this.$().text().trim(), '');\r\n});\r\n\r\n<\/pre>\n<p>It was an error message I never seen before, but sure enough it was a simple problem. I had this in my component handlebars template:<\/p>\n<pre>&lt;label data-test='label'=&gt;{{label}}&lt;\/label&gt; \r\n{{#if canEdit}} \r\n  &lt;div class=\"w-powerselect-addon\"&gt; \r\n  &lt;div class='w-powerselect-field' data-test='select-container'&gt;\r\n<\/pre>\n<div class=\"w-powerselect-addon\">Can you spot the error? Look closely at the &#8216;<strong>data-test=&#8217;label&#8217;=&gt;<\/strong>&#8216;. Somehow I left that second &#8216;<strong>=<\/strong>&#8216; (equal) sign there and it doesn&#8217;t make HTMLBars fail the compilation but at runtime it blows up with this weird error.<\/div>\n<div class=\"w-powerselect-addon\"><\/div>\n<div class=\"w-powerselect-addon\">Happy coding!<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hi Just wanted to do a quick post about this error I got when developing an EmberJS Application and trying to test a component (via an Integration test). The following error occurred while running the test: Error: Failed to execute &hellip; <a href=\"http:\/\/www.corrspt.com\/blog\/2015\/11\/06\/emberjs-failed-to-execute-setattribute-on-element-is-not-a-valid-attribute-name\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[49,50],"class_list":["post-401","post","type-post","status-publish","format-standard","hentry","category-emberjs","tag-emberjs","tag-testing"],"_links":{"self":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts\/401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/comments?post=401"}],"version-history":[{"count":2,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":403,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts\/401\/revisions\/403"}],"wp:attachment":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/media?parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/categories?post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/tags?post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}