I create a list of divs using an iron-list
like this:
<iron-list items="[[chats]]" as="item" style="height:500px;">
<template>
<div class="item title" data-recipient$="[[item.recipient]]">
<iron-icon class="big" src="../icons/games.svg"></iron-icon>
</div>
</template>
</iron-list>
I have a Polymer method which is called later-on and loops the div.title
.
I can then manage to set their color, but I can not manage to read out the data-attribute:
var elems = document.querySelectorAll(".title");
[].forEach.call(elems, function(el) {
el.style.color = "red"; // works
console.log(el.getAttribute("data-recipient")); // prints out null
});
Why is that?