Semantic-Org / Semantic-UI

Semantic is a UI component framework based around useful principles from natural language.
http://www.semantic-ui.com
MIT License
51.11k stars 4.94k forks source link

[Form] Fixes "remove rule(field)" throw exception if field has no rules #6940

Open jameschenjav opened 4 years ago

jameschenjav commented 4 years ago

Closed Issues

5745

Description

remove rule(field, rules) should remove all rules when argument rules is omitted. But field may not have any rules, and it would raise exceptions because of validation[field].rules = [].

There is some guard code to check if validation[field].rules exists, but the order is wrong apparently.

Testcase

https://jsfiddle.net/whd3o60j/3/

Click "Remove All Validations", raised exception Uncaught TypeError: Cannot set property 'rules' of undefined (in Chrome)

lubber-de commented 4 years ago

This is fixed in https://fomantic-ui.com See your same fiddle using fomantic here https://jsfiddle.net/x6h0bLrs/

jameschenjav commented 4 years ago

hi @lubber-de i noticed semantic-ui repo stopped updating after i created this PR and mentioned it to our dev team. i suggested to our team after saw your comment, and today we've decided to adopt fomantic-ui for further upgrades. thanks for the great work.