I've created an extension that'll let you do it.
In addition to
data-foo="bar", it'll also lets you use
(Inspired by this gist by Objective HTML)
I'm by no means a PHP/Add-on dev. I just wanted to 'have a go' too. Hopefully there's nothing wrong with it.
If any better-versed devs want to give it a once over, that'd be appreciated.