dom/builder: ensure attributes is a hash