Trying to populate a Polymer Element's <content></content> through an extended element

Keithamus

I have two elements: one is a <drop-down> element, the other is a <populated-drop-down> element. populated-drop-down extends drop-down, but, as you may have guessed, tries to pre-populate it with some options. The assumption was that I could simply put HTML inside the <shadow></shadow> tag, but this does not work:

<polymer-element name="drop-down" noscript attributes="label">
  <template>
    <style>
      :host{display:inline-block;border:1px solid;padding:1rem}
      #content{position:absolute}
      #drop, #content {display:none}
      #drop:checked + #content {display:block}
    </style>
    <label for="drop">{{label}}</label>
    <input type="checkbox" id="drop">
    <div id="content"><content></content></div>
  </template>
</polymer-element>


<polymer-element name="pop-drop-down" extends="drop-down" noscript>
  <template>
    <shadow>
      <ul>
         <li>Option1</li>
         <li>Option2</li>
         <li>Option3</li>
         <li>Option4</li>
         <li>Option5</li>
      </ul>
    </shadow>
  </template>
</polymer-element>


<drop-down label="Working DropDown">
      <ul>
         <li>Option1</li>
         <li>Option2</li>
         <li>Option3</li>
         <li>Option4</li>
         <li>Option5</li>
      </ul>
</drop-down>

<pop-drop-down label="Not working pre-populated dropdown">
</pop-drop-down>

(Code also available code on JSBin.)

It seems I am able to wrap additional tags around <shadow></shadow> but not place any inside of <shadow></shadow>

ebidel

IIRC, this was supported for a brief period of time in the Shadow DOM spec and Chrome's implementation. However, it was removed due to implementation concerns.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

polymer duplicate element content

From Dev

Bind data to content element in Polymer

From Dev

Polymer customelements's content get inserted below the element?

From Dev

Polymer customelements's content get inserted below the element?

From Dev

Append distributed child to <content> element in Polymer

From Dev

Using custom elements in the content element with polymer

From Dev

Extend polymer element - access parent content

From Dev

Polymer custom element with template-as-content

From Dev

Using custom elements in the content element with polymer

From Dev

Polymer custom element with template-as-content

From Dev

Polymer element in Chrome extension content script

From Dev

Get height of an element's content

From Dev

Trying to append a Polymer element in another Polymer element

From Dev

how to inject <template> into polymer component by providing it as element content

From Dev

populate select element with json data and return filtered content of json

From Dev

How to add dynamically extended element with Polymer?

From Dev

populate content based on list selection in Polymer

From Dev

Change color of an element based on it's content

From Dev

Search an element's content, excluding content of any children elements

From Dev

Search an element's content, excluding content of any children elements

From Dev

Replace another element content with hovered element content

From Dev

How to element content into new element

From Dev

One element's vertical alignment varies based on content of adjacent element

From Dev

Scale the element (and background) but not the content

From Dev

Using the Aurelia <content> element

From Dev

@keyframes change content of an element

From Dev

JAXB Multiple Content for Element

From Dev

Print content of element to console

From Dev

Get unparsed element content

Related Related

  1. 1

    polymer duplicate element content

  2. 2

    Bind data to content element in Polymer

  3. 3

    Polymer customelements's content get inserted below the element?

  4. 4

    Polymer customelements's content get inserted below the element?

  5. 5

    Append distributed child to <content> element in Polymer

  6. 6

    Using custom elements in the content element with polymer

  7. 7

    Extend polymer element - access parent content

  8. 8

    Polymer custom element with template-as-content

  9. 9

    Using custom elements in the content element with polymer

  10. 10

    Polymer custom element with template-as-content

  11. 11

    Polymer element in Chrome extension content script

  12. 12

    Get height of an element's content

  13. 13

    Trying to append a Polymer element in another Polymer element

  14. 14

    how to inject <template> into polymer component by providing it as element content

  15. 15

    populate select element with json data and return filtered content of json

  16. 16

    How to add dynamically extended element with Polymer?

  17. 17

    populate content based on list selection in Polymer

  18. 18

    Change color of an element based on it's content

  19. 19

    Search an element's content, excluding content of any children elements

  20. 20

    Search an element's content, excluding content of any children elements

  21. 21

    Replace another element content with hovered element content

  22. 22

    How to element content into new element

  23. 23

    One element's vertical alignment varies based on content of adjacent element

  24. 24

    Scale the element (and background) but not the content

  25. 25

    Using the Aurelia <content> element

  26. 26

    @keyframes change content of an element

  27. 27

    JAXB Multiple Content for Element

  28. 28

    Print content of element to console

  29. 29

    Get unparsed element content

HotTag

Archive