1

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?

timblack1
  • 137
  • 7
  • Probably related: http://stackoverflow.com/questions/31265782/data-binding-in-polymer-function-is-being-removed-from-bound-object – Scarygami Aug 04 '15 at 22:58
  • Thank you, @scarygami. Now I see that for some reason re-publishing hoodie-service.hoodie as a property named hoodie-accountbar.hoodie stripped out all of the hoodie object's methods, though it appears that publishing hoodie from hoodie-service did not have the same problem. – timblack1 Aug 04 '15 at 23:52

1 Answers1

0

@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.

timblack1
  • 137
  • 7