Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function parsePageContent(content, componentMap = DEFAULT_COMPONENT_MAP) {
const parser = new DOMParser();
const doc = parser.parseFromString(content, 'text/html');
const processingInstructions = buildProcessingInstructions(componentMap);
const bodyComponents = traverseWithInstructions(
doc.body.childNodes,
IsValidNodeDefinitions.alwaysValid,
processingInstructions,
);
const headComponents = traverseWithInstructions(
doc.head.childNodes,
IsValidNodeDefinitions.alwaysValid,
processingInstructions,
);
return { bodyComponents, headComponents };
}
export default function parsePageContent(content, componentMap = DEFAULT_COMPONENT_MAP) {
const parser = new DOMParser();
const doc = parser.parseFromString(content, 'text/html');
const processingInstructions = buildProcessingInstructions(componentMap);
const bodyComponents = traverseWithInstructions(
doc.body.childNodes,
IsValidNodeDefinitions.alwaysValid,
processingInstructions,
);
const headComponents = traverseWithInstructions(
doc.head.childNodes,
IsValidNodeDefinitions.alwaysValid,
processingInstructions,
);
return { bodyComponents, headComponents };
}