Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mix no longer deep copies for node values #236

Open
madhavs88 opened this issue Jan 12, 2023 · 0 comments
Open

Mix no longer deep copies for node values #236

madhavs88 opened this issue Jan 12, 2023 · 0 comments
Labels

Comments

@madhavs88
Copy link

I think I've found an issue with mixing no longer deep copying values after a recent update.

My case:

I use CSSO in my project, which in turn uses CSSTree.

CSSO calls (at least in one place) into CSSTree here, where it calls fork with an object with a couple of values. The key one is:

String: {
    generate(node) {
        this.token(TYPE.String, encodeString(node.value));
    }
}

This is then mixed into the main config. So the String value in the main config will be replaced by the above code block during the evaluation of this block.

The issue here is that mix completely overwrites the String entry in the config, which I suspect is because it does not deep copy it.

For instance, if the config is:

{
    ...,
    'node' = {
        ...,
        'String' = {
            'name' = 'foo',
            'structure' = ...,
            'generate' = ...,
        },
        ...,
    }
    ...,
}

and we attempt to mix that with the above String object from CSSO, we end up with:

{
    ...,
    'node' = {
        ...,
        'String' = {
            'generate' = ...,
        },
        ...,
    }
    ...,
}

Due to the way mix was rewritten in this commit, sliceProps ends up only creating a String object with whatever the incoming mixer has, instead of only selectively overwriting the individual fields of the objects with new versions.

I'm lodging the bug here as opposed to in CSSO because I feel like the expectation with mix is that it deep copies, and so the call from the CSSO side is correct.

This currently is not causing an issue with CSSO since they specify to use version ~2.2.0 of CSSTree, which is before this mix refactor occurred. Once they update their dependency the issue will become apparent from that side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants