Digging custom tags out of Polymer element definitions

46 views
Skip to first unread message

Bobby Richter

unread,
Apr 8, 2014, 4:30:15 PM4/8/14
to polym...@googlegroups.com
Dealing with some relics of the past in our elements' implementation, we've hit a snag reaching into <template>s externally to retrieve specific elements. For example, we leave a <script id="ceci-definition"> in our elements which contains some meta data about the element. Looks like this:
<polymer-element>
 
<template>
   
<script id="ceci-definition">{ ... }</script>
 
</template>
</polymer-element>

Later, we try to retrieve it using something ugly like this:
window.CustomElements.registry[elementName].prototype.element.impl.querySelector('template').content.querySelector('script#ceci-definition');


I'm in the process of moving those definition <script>s to be direct children of the <polymer-element> which encloses them, which makes reaching in for that data much easier. Like this:
<polymer-element>
  <script id="ceci-definition">{ ... }</script>
 
<template>
  </template>
</polymer-element>

and...
window.CustomElements.registry[elementName].prototype.element.impl.querySelector('script#ceci-definition');


My question: is there a cleaner, Polymer way to reach into the <polymer-element> tag for something?
Note: Trying not to place this meta data on the object which is passed to Polymer().

Also, cross-posted on StackOverflow in an effort to start moving more q&a there :). http://stackoverflow.com/questions/22947490/digging-custom-tags-out-of-polymer-element-definitions

Eric Bidelman

unread,
Apr 8, 2014, 4:43:58 PM4/8/14
to Bobby Richter, polymer-dev
I left I comment on StackOverflow. Let's continue the convo there so we can better understand the use case :)


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/eefa5a00-a13c-4301-bfb0-75bf0ef65c7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages