Open
Description
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
inherit
argument toparse()
),inherit
is set totrue
. In other words, inheriting is enabled by default. This is probably a design decision that I assume makes sense. - However,
inherit
also 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
?