-
Notifications
You must be signed in to change notification settings - Fork 514
BREP2
goldstar611 edited this page Oct 6, 2021
·
2 revisions
A magic dunder method providing a DOMNode view of the object (e.g. object.__as_node__() -> DOMNode) allowing objects to be used by the <= and + operators as DOMNodes.
This could be __as_node__ or any other acceptable method name.
The brythonic child (<=) and sibling (+) operators are used to easily construct DOM trees.
A discussion concerning this feature is on the google group
This suggestion improves brython in the following ways:
- Fixes clumsy syntax (e.g. Object.attach(DOMNode)) which <= was meant to avoid in brython
- Objects that wrap DOMNodes could now be used transparently as DOMNodes
- Slow python function calls (e.g. Object.attach(DOMNode)) would be replaced with faster javascript
- Testing demonstrated nearly double the speed for comparable operations. ###Status: Superseded###
Instead the functions in browser.html were replaced with objects that can be subclassed. This naturally allows the <= grammar to be used with these children.