[ToDo] Clarify in documentation that `.parent` is an internal property and not reliable on the node API
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17k
- Forks
- 3.4k
- Avg merge
- 7h 42m
- Merged PRs (30d)
- 26
Description
I'm Writing a ThemeColor Plugin, use Visitor.
In fn:visitColor , node.parent sometimes is null (box-shadow:0 0 0 1px #999 inset). I can't find the parent Declaration Node of Color Node.
so I want to less.js/lib/less/visitors/visitor.js Visitor.prototype.visit, funcOut.call(impl, node); => funcOut.call(impl, node, visitArgs);.
And my Code will be like this.
class ThemeVisitor {
visitDeclaration(node, visitArgs) {
node.isColorDeclaration = false;
visitArgs.isColorDeclaration = false;
return node;
}
visitColor(node, visitArgs) {
visitArgs.isColorDeclaration = true;
return node;
}
visitDeclarationOut(node, visitArgs) {
if (visitArgs.isColorDeclaration) {
node.isColorDeclaration = true;
}
return node;
}
visitRulesetOut(node) {
node.rules = node.rules.filter((item) => {
if (item instanceof Declaration) {
return item.isColorDeclaration;
}
if (item instanceof Ruleset) {
return !!item.rules.length;
}
});
return node;
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/less/src/less/visitors/visitor.js, especially Visitor.prototype.visit, and compare it with the issue's ThemeVisitor example. Update the relevant documentation to clarify that node.parent is an internal, unreliable property on the node API and make the supported behavior clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100