Set only data-* attributes with .setAttribute(), otherwise, use element properties.

Ensures that the rendered view is properly updated, e.g., when rendering to
input elements value attributes.