Winterfell icon indicating copy to clipboard operation
Winterfell copied to clipboard

Invalid custom inputTypes are not rejected

Open KingMob opened this issue 8 years ago • 2 comments

Pass in anything that's not a React Component to addInputType, and no exceptions will be thrown.

One issue is that ! has higher precedence than instanceof. So, in addInputType, the line:

!React.Component instanceof instance.constructor

is actually negating React.Component, not the result of the instanceof test.

However, wrapping it in parentheses like !(React.Component instanceof instance.constructor) doesn't fix the overall issue, so I think there's something wrong with the instanceof test, too.

KingMob avatar Feb 20 '18 18:02 KingMob

Ahh. This may have been a time thing, those validation checks have probably changed over time, and Winterfell hasn't kept up with that. I'll do some digging on this, and work out what the best validation check is.

Happy to accept PRs too! :)

andrewhathaway avatar Feb 21 '18 16:02 andrewhathaway

I was going to submit a PR, but the handful of things I tried didn't work. I'm not too clear on how React's object hierarchy works under the hood, unfortunately. I've mostly left Javascript for Clojurescript these days, so my esoteric knowledge about Js prototype stuff is dwindling...

KingMob avatar Feb 21 '18 17:02 KingMob