Improving unregistering metafields in metaforms.js #2812
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added the ability to unregister meta fields by
name
,templateUrl
or a custom search predicate callbackWe originally did that in a custom module of ours, and @EugeneOkhriemnko suggested I create a PR here so everyone can benefit.
Since there is no real method overloading in js, I did some
_.isFunction
magic to allow the same method ~group to accept the 3 different types of values formetaFieldToFind
: name, function callback or object reference.I added an error message because I think it's better t have an error than to silently not remove a field, but that could be considered a breaking change since the previous code didn't throw an error, if preferred this could be changed so that it only throws on error if
metaFieldDescription
, or not throw at all, or having this error throwing behaviour configured somewhere I don't know.I tried to stay backwards compatible with the way
unregisterMetaFields
worked before, i.e it accepts an object reference inmetaFieldToFind
.References
Sorry I have no idea what to put in this section.
QA-test:
Jira-link:
Artifact URL: