jsx-vue2 icon indicating copy to clipboard operation
jsx-vue2 copied to clipboard

feat(babel-sugar-inject-h): add support for functional jsx `h` injections

Open allex opened this issue 3 years ago • 0 comments

Add support for purge functional jsx construct with h be auto injected. eg.

const compGenerator = (funcRender, customize) => { /* factory for variant components generator */ }

const Foo = compGenerator((ctx) => (
  <C { ...ctx } scopedSlots={{
    foo: ({ value }) => (<Item value={ value } />)
  }} />
), {})

=>

var compGenerator = function (funcRender, customize) { /* factory for variant components generator */ };

var Foo = compGenerator(function (h, ctx) {
  return h("C", _mergeJSXProps([{}, ctx, {
    "scopedSlots": {
      foo: function foo(_ref) {
        var value = _ref.value;
        return h("Item", {
          "attrs": {
            "value": value
          }
        });
      }
    }
  }]));
}, {});

Also support any purge functional render-like code snippet:

new Vue({
  ...
  foo: function () { return <C /> }
  render: () => <App />
})

=>

new Vue({
 ...
  foo: function (h) { return h(<C />) }
  render: (h) => h(<App />)
})

allex avatar Nov 17 '20 07:11 allex