Skip to content

eachDeep with childrenPath == wrong parent, parent path etc #143

@AlexanderTheGr8-gr

Description

@AlexanderTheGr8-gr

I will start by saying, THANK YOU(!) for this great library (the Deepdash part of Loadash).

I have a simple structure,

window.inheritanceTree = {
    "variable": {
        "0": "string",
        "number": {
            "0": "int",
            "1": "float",
            "2": "double",
            "decimal": [
                "float",
                "double"
            ]
        }
    },
    "0": "template",
    "1": "view",
    "2": "data"
};

And then I make a simple call:
_.eachDeep(window.inheritanceTree, function(){console.log(arguments)}, {childrenPath: ['variable.number.decimal']});

The expected output for "float" for example would be: Arguments[2] == Array(2)['float', 'double']
or even: Arguments[2] == Object{0: 'int', 1: 'float', 2: 'double', 'decimal': Array[...]}

But instead I get:
Arguments[2] == Object{0: 'template', 1: 'view', 2: 'data', "variable": {...} }
which is the object I passed to _eachDeep in the first place...

I guess it has to do with how depth is calculated, that 'float' is in depth 1 under 'childrenPath', and that confuses the code to return the root element... But that's only a speculation after seeing a little the code of _eachDeep.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions