use properties rather than DOM attributes

Fixes #1.