Skip to content

Misc changes + 0.4.2 version bump #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2019
Merged

Misc changes + 0.4.2 version bump #56

merged 3 commits into from
May 27, 2019

Conversation

rmorshea
Copy link
Collaborator

Summary

Fixes several things:

  1. html_to_vdom did not return the whole HTML model.
  2. Reworks how the transform function is applied to the model after its been converted to VDOM.
  3. Fixes typing issue with Element function signature.

Return whole HTML model

If your html looked like this:

<div/>
<p/>

The function only returned the model for the first div. Now it returns a wrapper div around both elements.

Reworks how transform is applied

The transform was a little difficult to work with given the time at which it was applied. It's more intuitive for the transform to get applied from the root node to leafs rather than the other way around. It also makes the underlying code a little easier to reason about.

Fix Element function protocol type

The Element functions signature was previously defined by a Protocol with a __call__ attribute, however this didn't really work as expected.

I wanted to enforce (self: Element, *args: Any, **kwargs: Any) where *args, **kwargs was actually optional (i.e. functions conforming to the protocol could accept any, or no other arguments besides self).

See python/mypy#5876 for details.

Fixes an issue with typing for element functions - protocol from
typing extensions does not produce correct behavior. Variable
positional and keyword arguments should be optional and not
required.

Reworked html to vdom function output. Before it ignored the
possibility of having multiple "root" elements - now, we wrap
whatever models are produced in a div and the children are the
roots of the html that was passed.

Allows multiple transforms to be passed for html to vdom and changes
how they are applied. Now they are run from roots to leafs instead
of the other way around. Feels easier to thing about that way.
@rmorshea rmorshea force-pushed the html-to-vdom-fixes branch from ff96eab to ca39a1f Compare May 27, 2019 01:26
@@ -41,18 +41,18 @@ def handle():
return idom.node("button", "Use" eventHandlers=events)
"""

__slots__ = ("__current",)
__slots__ = ("_current",)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__current conflicted with something in Generic

@rmorshea rmorshea merged commit 35b4496 into master May 27, 2019
@rmorshea rmorshea deleted the html-to-vdom-fixes branch May 27, 2019 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant