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

TypeError: Cannot read properties of null (reading 'isSelfCloseTag') #34

Open
Cheng007 opened this issue Mar 9, 2024 · 8 comments
Open
Assignees

Comments

@Cheng007
Copy link

Cheng007 commented Mar 9, 2024

There is an error TypeError: Cannot read properties of null (reading 'isSelfCloseTag') while parsing from the following html string:

const htmlString = `<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Webpack App</title>
  <meta name="viewport" content="width=device-width, initial-scale=1"><script defer src="main.bundle.js"></script></head>
  <body>
  </body>
</html>`;

It directly caused by the following unhandled null input element

function isElementComposed(element, tag) {
    if (!tag) {
        return false;
    }
    const isCloseTag = closeTagExp.test(tag);
    const [, nodeName] = tag.match(nodeNameExp) || [];
    const isElementClosedByTag = isCloseTag && element.nodeName === nodeName;
    return isElementClosedByTag || element.isSelfCloseTag || element.nodeType === Node_1.NodeType.text;
}
@Cheng007
Copy link
Author

I submitted a PR and hope this will help

@mister-teddy
Copy link

Please review the PR #35, folks! I'm having the same issue.

@carafelix
Copy link

Same here

@BernhardBehrendt
Copy link

same here

@lookus69
Copy link

me too! please solve this!!
thanks!

@jpazer
Copy link

jpazer commented Sep 19, 2024

Me too!

@thepeski
Copy link

Same here ;)

@ershov-konst ershov-konst self-assigned this Oct 16, 2024
@anas-netixsol
Copy link

same issue

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

9 participants