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

<template> children are not parsed correctly on the client #414

Closed
remarkablemark opened this issue Mar 4, 2023 · 1 comment · Fixed by #415 or #416
Closed

<template> children are not parsed correctly on the client #414

remarkablemark opened this issue Mar 4, 2023 · 1 comment · Fixed by #415 or #416
Assignees
Labels

Comments

@remarkablemark
Copy link
Owner

Expected Behavior

import parse from 'html-dom-parser';

parse('<template>test</template>');

Output:

[
  {
    "parent": null,
    "prev": null,
    "next": null,
    "startIndex": null,
    "endIndex": null,
    "children": [
      {
        "parent": "[Circular]",
        "prev": null,
        "next": null,
        "startIndex": null,
        "endIndex": null,
        "data": "test",
        "type": "text"
      }
    ],
    "name": "template",
    "attribs": {},
    "type": "tag"
  }
]

Actual Behavior

import parse from 'html-dom-parser';

parse('<template>test</template>');

Output:

[
  {
    "parent": null,
    "prev": null,
    "next": null,
    "startIndex": null,
    "endIndex": null,
    "children": [],
    "name": "template",
    "attribs": {},
    "type": "tag"
  }
]

Steps to Reproduce

Open ./examples/index.html in a browser and enter the HTML:

<template><article><p>Test</p></article></template>

See the output children is [].

Reproducible Demo

Environment

  • Version: 3.1.3
  • Platform:
  • Browser: Chrome
  • OS:

Keywords

template

@remarkablemark remarkablemark self-assigned this Mar 4, 2023
@remarkablemark
Copy link
Owner Author

The bug is caused by this line: https://github.com/remarkablemark/html-dom-parser/blob/v3.1.3/lib/client/utilities.js#L86

Since <template> node's children are on node.content.childNodes

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