You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been trying to inject a class name into a parsed HTMLElement and when I call rootNode.toString(), the class does not appear. Printing the element that gets fed into .exchangeChild does infact show the class, though.
Am I doing something wrong, or is there perhaps a workaround?
const targetElement = node as HTMLElement;
const parentElement = targetElement.parentNode as HTMLElement;
const component = createComponent(targetElement.tagName);
const renderedComponentHtml = minify(component.render(targetElement.attributes, targetElement.innerHTML));
const renderedElement = parse(renderedComponentHtml) as HTMLElement;
if (options.injectClass) {
const childElement = renderedElement.childNodes[0] as HTMLElement;
childElement.classNames = [targetElement.tagName];
console.log(renderedElement.childNodes[0]);
}
parentElement.exchangeChild(targetElement, renderedElement);
I have been trying to inject a class name into a parsed HTMLElement and when I call rootNode.toString(), the class does not appear. Printing the element that gets fed into .exchangeChild does infact show the class, though.
Am I doing something wrong, or is there perhaps a workaround?
Output:
The text was updated successfully, but these errors were encountered: