Polymer 1.0 postMessage

102 views
Skip to first unread message

eric sherouse

unread,
Jul 16, 2015, 9:28:07 PM7/16/15
to polym...@googlegroups.com
Hello,

I am migrating my app from Polymer 0.5 to 1.0. I have an element with an embed tag in it (used to communicate with a Native Client module actually).

<embed id="theThing" src="{{nmf}}" type="application/x-pnacl" on-load="loaded" on-message="receive">

In 0.5, I was able to use postMessage to communicate with this embed element like this:

this.$.theThing.postMessage()

In 1.0, it appears I can no longer access the postMessage method (it is undefined). I have tried multiple element selector variations:

Polymer.dom(this.$.theThing).postMessage(); //does not work
this.$$("#theThing").postMessage(); //does not work
Polymer.dom(this.root).querySelector("#theThing").postMessage(); //does not work


Is there a new way to access these sorts of methods? If this is described in the docs, I have missed it so far. Any thoughts would be appreciated.

Thanks,
Eric

Eric Bidelman

unread,
Jul 16, 2015, 10:16:07 PM7/16/15
to eric sherouse, polym...@googlegroups.com
Did you try just this.$.theThing.postMessage()? Since that node is local to your element's DOM, you shouldn't need the Polymer.dom() wrappers. Those are mainly for cases where you're manipulating the light DOM of an element and doing
things that could affect distribution.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/a4acb0ab-765c-49f6-823c-66d1e1c76d3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

eric sherouse

unread,
Jul 16, 2015, 10:29:35 PM7/16/15
to polym...@googlegroups.com, sher...@gmail.com
Thanks for the quick reply. Yes, I also tried this.$.theThing.postMessage(), and it does not work either.

eric sherouse

unread,
Jul 20, 2015, 3:42:11 PM7/20/15
to polym...@googlegroups.com
FYI, I just looked at this again. The problem was that I was trying to call the postMessage() function before the local DOM was ready. Basic.

Eric
Reply all
Reply to author
Forward
0 new messages