New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
innerHTML broken for template elements #451
Comments
get innerHTML from happy-dom/packages/happy-dom/src/nodes/element/Element.ts Lines 170 to 177 in faaaa2c
but the div element not in this.childNodes. happy-dom/packages/happy-dom/src/nodes/html-template-element/HTMLTemplateElement.ts Lines 21 to 26 in faaaa2c
so we should overwrite innerHTML like this(maybe error for my understand to sources code): add code in /**
* Returns inner HTML.
*
* @returns HTML.
*/
public get innerHTML(): string {
const xmlSerializer = new XMLSerializer();
let xml = '';
for (const node of this.content.childNodes) {
xml += xmlSerializer.serializeToString(node);
}
return xml;
}
/**
* Sets inner HTML.
*
* @param html HTML.
*/
public set innerHTML(html: string) {
super.innerHTML = html;
} @capricorn86 Is this a good answer? |
Thanks. I'll monkey-patch that fix if I detect it to be necessary in my project. Also thanks for maintaining this awesome project! If you want you can close this. |
…html-template #451 fixes missing inner html in html template
Thanks to @Mas0nShi we now have support for I will add some additional unit tests as well in a separate PR. You can read more about the release here: |
Now when I'm writing more unit tests I have realized that the logic is not complete. I will re-open this ticket. |
We finally have a fix in place that should resolve the remaining issues related to the You can read more about the release here: |
Test case:
Output in
"<div>happy-dom is cool!</div>"
"<div>happy-dom is cool!</div>"
"<div>happy-dom is cool!</div>"
""
Expectation
happy-dom should behave like every other tested DOM.
Motivation
This breaks the integration into solid-register, which uses a dom on top of node to test solid code fast.
The text was updated successfully, but these errors were encountered: