kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

Very strange exception #276

Closed nandin-borjigin closed 8 years ago

nandin-borjigin commented 8 years ago

vue & vue-validator version

1.0.25, 2.1.3

Reproduction Link

The problem is heavily related to development environment, so I can't make a minimal reproduction sample.

Steps to reproduce

<validator name="validation">
    <input v-validate:input="['required']">
</validator>

It still caused the exception. And then, the VERY STRANGE thing happened:

  1. First, I commented this testing code out, and webpack-dev-server reloads the page and the page rendered correctly.
  2. Then I uncommented this testing code and webpack-dev-server made a HOT-UPDATE to apply the changes, it worked, the page got rendered correctly and validator worked fine ( I inspected the dom element and it's css class name changed according to my input).
  3. Finally, I made a manual full reload, i.e. pressing Command + R(ctrl + R for windows) to reload the page, that exception comes back. The code was totally untouched between step 2 and 3, but the result was different.

I added a exception break point , and that exception comes from resolveAsset function, which is called from BaseValidation.prototype._resolveValidator.

The incoming arguments of resolveAsset function looks like:

function resolveAsset(options, type, id, warnMissing) {
    // ... some code
    var assets = options[type] // assets = undefined here, because options don't have a property named validators, I think this is the point
    var res = assets[id] // throws exception because assets = undefined

}

It's very strange because hot-updating doesn't cause this exception but full reload does. I don't know if the details above are enough to figure out what's going wrong.

nandin-borjigin commented 8 years ago

I found a similar issue #188, the exception stack is extremly identical I've tried to import and install validator before router, but it's still not working

kazupon commented 8 years ago

related #130

nandin-borjigin commented 8 years ago

Solved, watch my comment on issue 130