In a view I need to add a custom data-attribute to the row output (just like classes are added). Simply rewriting the output doesn't work because XSS attribute filtering strips the attribute. How can I accomplish this in a reasonable way? These answers are for D7 and do not quite cover dynamic output:
To summarize for future reference:
You can add data attributes using Rewrite in Views Fields.
If you added a custom data-attribute but something isn't working, the problem might be in the value ;)
What gets stripped by the
filter_xss_admin() on Rewrite is most notably the
<object> tag and
style="" attribute because users can submit malicious code through those.
It seems Views for D7 will have that check removed in the next release: Remove filter_xss_admin() from result rewriting because views editors are already trusted admins