1

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

1
  • One thing I noticed is when I use data- attribute to bind data the changes are not getting triggered to the bounded attribute Commented Feb 27, 2014 at 18:16

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Just to add... we recommend custom attributes because you can publish properties in Polymer as attributes. This allows you to take advantage of Polymer's data-binding features and <prop>Changed() handlers. data-* attrs aren't observable in the same way to Polymer's internals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.