Skip to content
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

bug caused by getElementById type #1665

Open
missannil opened this issue Apr 7, 2024 · 0 comments
Open

bug caused by getElementById type #1665

missannil opened this issue Apr 7, 2024 · 0 comments

Comments

@missannil
Copy link

missannil commented Apr 7, 2024

const dom: Domhandler.Document = htmlparser2.parseDocument(wxmlText, {
xmlMode: true,
});
In I use domUtils. GetElementsByTagName (' tagName, dom), I can pass in the dom, and get the expected element
In domUtils.getElementsById('eleId',dom), the ts type allows me to pass in the dom, but it doesn't get the correct result (null).

Found in the getElementsByTagName source code first made an 'isTag' judgment on the passed parameter (dom), which caused the dom to not enter the subsequent logic, because the dom tag is' root '.
This is obviously confusing, and hopefully ts will be more rigorous about the types of parameters passed in.

I now use domUtils.getElementsById('eleId',dom.children) as such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant