dom/element: improve attribute handling