polymerpolymer-1.0hoodie

Uncaught TypeError: this.hoodie.account.signUp is not a function


Why does my element throw the following error when it's served through an iron-component-page element (in a Polymer Seed Element demo), but not when served normally through my app?

Uncaught TypeError: this.hoodie.account.signUp is not a function

The demo is published at http://timblack1.github.io/hoodie-accountbar/components/hoodie-accountbar/.

this.hoodie should be created by hoodie.js, which does load according to Dev Tools' Network tab. But the this.hoodie object doesn't contain as many methods and attributes as it should, including the .account.signUp() method. this.hoodie.account exists, but only as an empty object.

I'm loading hoodie.js via a <script> tag in the hoodie-service element, which is loaded by hoodie-accountbar. Does the iron-component-page element do anything funny when it loads tags in a demo element? Or does hydrolysis?


Solution

  • @scarygami's comment pointed the way to the fix. The problem is that published properties are run through JSON.stringify(), which strips out any methods defined on those published property objects. So I fixed this error by no longer making the hoodie property be a published property on the hoodie-accountbar element. The fix is at https://github.com/timblack1/hoodie-accountbar/commit/db8d3071e4ad53a71b3d0e834075f00967c2e4a4.