flexxui / flexx

Write desktop and web apps in pure Python
http://flexx.readthedocs.io
BSD 2-Clause "Simplified" License
3.25k stars 257 forks source link

How do I set "data-xxx" attributes on widgets? #716

Open TreyBoudreau opened 2 years ago

TreyBoudreau commented 2 years ago

I'd like to set a data attribute on widgets, as per https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

I've tried using create_element('div', {'data-my-prop': 'my value'}, ...) but something in Flexx seems to strip them out.

Any clues?

almarklein commented 2 years ago

I wonder whether the way the attribute is set works: https://github.com/flexxui/flexx/blob/69b85b308b505a8621305458a5094f2a6addd720/flexx/ui/_widget.py#L502

Could be that node.setAttribute is needed.