Skip to content

Pattern defaults are controlled by inherit in ArgumentParser.parse() #627

Open
@fulv

Description

@fulv

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;
  1. By default (i.e. if one does not pass an inherit argument to parse()), inherit is set to true. In other words, inheriting is enabled by default. This is probably a design decision that I assume makes sense.
  2. However, inherit also controls whether a pattern's defaults should be used (line with var 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions