trueadm / t7

Lightweight virtual DOM templating library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to handle splats (spread operator)

a-s-o opened this issue · comments

Hi, thanks for you work on this library. I have just started using it and I like the way that components are handled.

I am wondering if there is any way to handle splats. They are useful in JSX for higher order components. For example doing the following in JSX:

function Component (props) {
  return (
    <input class='Input'  onInput={this.onInput} {...props} />
  );
}

Effectively, we don't know or don't care about the income props (or whatever arbitrary object) and we want to simply relay it down to a tag. If not supported, would you consider adding this? I can attempt a pull request if you are interested.

I suppose we could check whether a preceding literal ends with ... and then assign the immediately following substitution to the props. For example:

<input class='Input' onInput=${this.onInput} ...${props} />

I'd be happy to take a PR for this addition :)

Thanks for your help