Skip to content

Dodrio support with a bespoke macro.#38

Merged
bodil merged 6 commits intomasterfrom
dodrio
Mar 16, 2019
Merged

Dodrio support with a bespoke macro.#38
bodil merged 6 commits intomasterfrom
dodrio

Conversation

@bodil
Copy link
Copy Markdown
Owner

@bodil bodil commented Mar 16, 2019

This isn't very modular, but this PR adds a dodrio! macro behind a feature flag which bypasses the usual DOMTree -> VNode -> native song and dance and generates dodrio::builder code directly in the macro.

It still populates a typed_html::elements struct with attribute values so that we still have proper type checking, but instead of keeping these structs around in a full tree to be rendered later, the attributes are stringified on the spot and fed directly to dodrio::builder::ElementBuilder.

Alas, event handlers all take Event rather than a refined type because that's all Dodrio's API allows for. On the bright side, because they all have the same type, there's no need to construct a giant event handler struct to type check them all, and we just bypass that bit entirely and pass the functions directly on to Dodrio without any further indirection.

Testing has been sparse, but the basic "counter" example from Dodrio (in examples/dodrio) works.

Copy link
Copy Markdown

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

This is super awesome! What quick work!

I'm not familiar with the proc macro's implementation but I've left a small note below. Its the kind of thing that isn't a big deal, and could definitely be pushed off into a follow up issue to be addressed at a later date :)


dodrio!(bump,
<div>
<button onclick={|root, vdom, _event| {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wow! 😍

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.

2 participants