-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
can not parse correctly html with nested ul and li tags. #1039
Comments
I think I've got a similar issue. I thought I'd post it here rather than make a new issue - but I can do that if it's clearer.
import { Window } from 'happy-dom';
const window = new Window({
url: 'https://localhost:8080',
width: 1024,
height: 768,
});
const document = window.document;
document.body.innerHTML =
'<ul id="ul"><li id="li1">item 1</li><li id="li2"><ul ><li >trap</li></ul></li><li id="li3">item 3</li></ul>';
console.log(document.body.outerHTML);
window.happyDOM.cancelAsync(); gives: <body><ul id="ul"><li id="li1">item 1</li><li id="li2"><ul></ul></li><li>trap</li></ul><li id="li3">item 3</li></body>
|
I also have this issue. Did the author have some questions for solving the issue? |
It seemed that the problem happened when putting the The best method is to rewrite |
This is a patch. import UnnestableElements from 'happy-dom/lib/config/UnnestableElements.js'
delete UnnestableElements.LI |
Due to parsing issues, see: - capricorn86/happy-dom#1126 - capricorn86/happy-dom#1039 - capricorn86/happy-dom#1237 - capricorn86/happy-dom#954
Update tests to reflect the change and also ensure that nesting is removed from all non-nestable elements.
Thanks @lovetingyuan, we've encountered the same issue that left us scratching our heads when writing tests. We also found that, as @tq-xyy suggests, removing I've submitted a PR with this fix and updated the tests accordingly. |
Update tests to reflect the change and also ensure that nesting is removed from all non-nestable elements.
Thank you for contributing @danbentley! 🌟 I'm currently working on an implementation for this as well: The problem is that Example var container = document.createElement('div');
container.innerHTML = '<li><li><span>Test</span></li></li>';
// Outputs "<li></li><li><span>Test</span></li>"
console.log(container.innerHTML); Spec |
Thanks @capricorn86 for the explanation, it makes sense and it's something that occurred to me. I suppose some elements are more "unnestable" than others, with Sounds like an interesting challenge. I'm looking forward to see how you solve it! |
…able>) doesn't allow itself as direct descendant when parsed, but should allow itself as descendant when it is not at first level
The problem should be fixed now 🙂 You can read more about the release here: |
Describe the bug
can not parse correctly html with nested ul and li tags.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
the right answer is
Device:
The text was updated successfully, but these errors were encountered: