Small JavaScript helper for working with the `data-state` attribute of an element