Skip to content

vdom 0.3

Compare
Choose a tag to compare
@rgbkrk rgbkrk released this 22 Sep 18:01
· 171 commits to main since this release

vdom

Write declarative layouts in Python, today! Now with cleaner interfaces that work out of the box. πŸŽ‰

pip install vdom

Deprecations

This cleans up probably the biggest misstep we could have made when starting this which was making a function called createElement that doesn't actually create the VDOM Element. It creates something more similar to creating a component which can create elements later (it's a factory...).

createElement is deprecated in favor of createComponent. We kept it backwards compatible with the last release (0.2), keeping it in for now (it's only been a week, but we might as well be kind).

That being said, there are some niftier helpers you may like better! See below for more.

New Functions

createComponent

createComponent is exactly the same as what createElement did before, with a better name.

>>> marquee = createComponent('marquee')
>>> marquee('woohoo')
<marquee>woohoo</marquee>

h

Wait, did you pick a single letter for a function?

Yes, yes we did. Ok, it's not us. This comes by way of preact and hyperscript, allowing you to write condense React.createElement style writing:

>>> h('div', [h('p', 'hey')])
<div><p>hey</p></div>

We don't have JSX in Python, so this is the closest we can really get. πŸ˜‰

Helpers

The h1, img, and other HTML elements are still created here, they're left alone for backwards compatibility. These were put in to be similar to hyperscript-helpers.

Bug fix

Prior to this, you had to wrap VDOMEls in a call to VDOM(). That's no more, as VDOMElements provide the repr properly now:

screen shot 2017-09-22 at 8 11 32 am