mohanaravind
mohanaravind

Reputation: 133

Usage of data attribute VS custom element attribute

I understand that create a custom attribute on a custom element in Polymer allows us to watch for changes to that attribute by specifying a listener. But if I just need to expose a data from my custom element when do I use data attribute and when to use a Polymer's custom attribute?

I also understand that data- takes only strings

Upvotes: 1

Views: 340

Answers (1)

robdodson
robdodson

Reputation: 6786

I think you'll pretty much always want to use Polymer's custom attributes unless your attribute has the same name as a built-in attribute (like title). As you noticed, the change handlers will not work with data- attributes.

Upvotes: 1

Related Questions