Pattern defaults are controlled by `inherit` in ArgumentParser.parse()
Here are the first eight lines of ArgumentParser.parse():
parse: function argParserParse($el, options, multiple, inherit) {
if (typeof options==="boolean" && multiple===undefined) {
multiple=options;
options={};
}
inherit = (inherit!==false);
var stack = inherit ? [[this._defaults($el)]] : [[{}]];
var $possible_config_providers = inherit ? $el.parents().andSelf() : $el,
final_length = 1;
- By default (i.e. if one does not pass an
inheritargument toparse()),inheritis set totrue. In other words, inheriting is enabled by default. This is probably a design decision that I assume makes sense. - However,
inheritalso controls whether a pattern's defaults should be used (line withvar stack =...).
Thus, if one wants to disable inheritance from DOM parents, one also loses all the defaults set in the pattern (e.g. parser.addArgument(...)).
And viceversa: if I wanted to omit the defaults in my pattern, I would not be able to inherit some values from the element's parents.
What is the justification for this choice of overloading inherit?
@fulv I fear I can't answer that question, I believe that was done way ago by Wichert. What is the impact of not answering this?
I guess what I was really asking was whether it would make sense to decouple the parent inheritance from the local defaults. But I imagine it might be hard to assess the impact of such a change.
Fulvio
On Fri, Feb 28, 2020 at 2:23 AM Alexander Pilz [email protected] wrote:
@fulv https://github.com/fulv I fear I can't answer that question, I believe that was done way ago by Wichert. What is the impact of not answering this?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Patternslib/Patterns/issues/627?email_source=notifications&email_token=AADQPRSXDCULQPTG3WMHSCLRFDQYJA5CNFSM4F66MEFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENIA3BY#issuecomment-592448903, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQPRWHAY6X5TJL4JEH4PDRFDQYJANCNFSM4F66MEFA .