jridgewell / babel-plugin-transform-incremental-dom

Turn JSX into IncrementalDOM
MIT License
144 stars 12 forks source link

Support skip. #70

Closed zandaqo closed 7 years ago

zandaqo commented 7 years ago

Hi,

It's a bit puzzling that this plugin doesn't support iDOM's skip since the feature is instrumental in creating nested components. Is there some inherent problem with JSX or iDOM that is blocking this feature? Or is there a simpler workaround imitating skip in JSX that I am not aware of?

jridgewell commented 7 years ago

There's no direct JSX syntax that would allow you to tell the transform that you want to skip. Components are very close (and we'll likely skip inside them), but iDOM just added support for them.

zandaqo commented 7 years ago

In that case, I propose using skip attribute of an element as the signal to call skip inside the element. That is, translating this:

<div skip></div>

into this:

elementOpen("div");
  skip();
elementClose("div");

I have come up with an ad-hoc implementation in my fork, if you are interested in this approach, I can polish it up and submit a pull request.

jridgewell commented 7 years ago

Sure. Few points:

zandaqo commented 7 years ago

I have updated my commit to address those points. It now uses __skip by default, and the attribute name can be changed by setting skipAttribute option. Components are also skipped. Can you take a look at the code? It passes all the tests, though I'm having hard time setting up eslint, so not sure about the style.

jridgewell commented 7 years ago

Yah, that looks fine.