Files
dealplustech/node_modules/svgo/lib/util/map-nodes-to-parents.js
Kunthawat Greethong 443c3377e2 refactor: Move Astro to root, use PORT env (default 80), allow all hosts
- Move Astro files from dealplustech-astro/ to project root
- Update Dockerfile: PORT environment variable (default 80)
- Add vite.config.ts with allowedHosts: true
- Matches nixpacks behavior for Easypanel deployment
- No hardcoded ports or domains
2026-03-03 11:40:50 +07:00

30 lines
668 B
JavaScript

import { visit } from './visit.js';
/**
* Maps all nodes to their parent node recursively.
*
* @param {import('../types.js').XastParent} node
* @returns {Map<import('../types.js').XastNode, import('../types.js').XastParent>}
*/
export function mapNodesToParents(node) {
/** @type {Map<import('../types.js').XastNode, import('../types.js').XastParent>} */
const parents = new Map();
for (const child of node.children) {
parents.set(child, node);
visit(
child,
{
element: {
enter: (child, parent) => {
parents.set(child, parent);
},
},
},
node,
);
}
return parents;
}