nickmessing / babel-plugin-jsx-v-model

JSX Syntactic Sugar Plugin for v-model
MIT License
155 stars 12 forks source link

bug : different order of `v-model` ,`on-input` will lead to different result #15

Open nailfar opened 5 years ago

nailfar commented 5 years ago
<input  
   onInput={this.onChange}
   v-model={this.val}
 >

compile to :

h(
  "textarea",
  __WEBPACK_IMPORTED_MODULE_1_babel_helper_vue_jsx_merge_props___default()([
    {
      on: __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty___default()(
        {
          input: function input(e) {
            return _this.onChange(e);
          }
        },
        "input",
        function input($$v) {
          _this3.val = $$v;
        }
      )
    },
    {
      directives: [
        {
          name: "model",
          value: _this3.val
        }
      ]
    },
  ])
);

the "input" event of "onInput" will be override

<input  
   v-model={this.val}
   onInput={this.onChange}
 >

compile to :

h(
  "textarea",
  __WEBPACK_IMPORTED_MODULE_1_babel_helper_vue_jsx_merge_props___default()([
    {
      on: {
        input: function input($$v) {
          _this3.val  = $$v;
        }
      }
    },
    {
      directives: [
        {
          name: "model",
          value: _this3.val
        }
      ]
    },
    {
      on: {
        input: function input(e) {
          return _this.onChange(e);
        }
      },
    }
  ])
);