I have a simple polymer element that looks like this:
<link rel="import" href="../../bower_components/polymer/polymer.html"> <dom-module id="selector-course"> <template> <style> paper-dropdown-menu { padding:5px; } </style> <paper-dropdown-menu label="Course"> <paper-listbox class="dropdown-content" selected="{{selected}}" attr-for-selected="value" id="courseSelect"> <paper-item value="main">Main</paper-item> <paper-item value="soup">Soup</paper-item> <paper-item value="dessert">Dessert</paper-item> <paper-item value="appetizer">Appetizer</paper-item> </paper-listbox> </paper-dropdown-menu> </template> <script> Polymer({ is: 'selector-course' }); </script> </dom-module>
This element is stored in a separate HTML file and then used in several of my other elements:
<link rel="import" href="components/selector-course.html"> ... <selector-course selected="{{recipe.course}}"></selector-course>
Now, in my parent elements, I need to access the selected <selector-course> value
Now I have a solution that looks like this:
this.shadowRoot.querySelector('selector-course').shadowRoot.querySelector('#courseSelect').selectedItem.getAttribute("value");
This works, however, this query seems absurdly complicated for such a trivial task as accessing an element property.
Is there an easier way to achieve the same?
source share