Skip to content

fix: set parent pointers for constructor children - #382

Open
Boulea7 wants to merge 1 commit into
postcss:mainfrom
Boulea7:ln-cx/fix-selector-constructor-parents
Open

Boulea7 wants to merge 1 commit into
postcss:mainfrom
Boulea7:ln-cx/fix-selector-constructor-parents

Conversation

@Boulea7

@Boulea7 Boulea7 commented Dec 2, 2026

Copy link
Copy Markdown

In a PostCSS transform, selector({ nodes }) renders its children without setting their parent. Calling obsolete.remove() in this example leaves .obsolete.kept in the output instead of .kept.

const obsolete = parser.className({ value: "obsolete" });
const kept = parser.className({ value: "kept" });
const selector = parser.selector({ nodes: [obsolete, kept] });
obsolete.remove();
selector.toString(); // Expected: ".kept"

Set the parent for supplied children that do not have one. A selector constructed for preview can still reuse an attached node while its original selector owns it. The regressions exercise removal in both cases.

On macOS, 1,159 unit tests and five property test groups passed on both Node 22.23.5 and 26.13.1. Lint and typecheck passed.

Implemented and tested with OpenAI Codex (gpt-6.2-sol).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant