Skip to content

Schema ancestors are not respected #8

@emilnordh

Description

@emilnordh

Subject of the issue

A schemas ancestors property is not respected.

Your environment

  • OS: macOS 10.15.2
  • Packages: hast-util-sanitize@3.0.1, rehype-sanitize@4.0.0
  • Env: Node@12.14.1 npm@6.13.4

Steps to reproduce

Simple schema:

{
  "ancestors": {
    "li": ["ul"]
  },
  "tagNames": [
    "div",
    "ul",
    "li"
  ]
}

HTML:

<div>
  <li>List Item</li>
</div>

Expected behavior

Expecting the resulting tree to exclude the li tag:

root[1]
│ data: {"quirksMode":true}
└─0 element<div>[3]
    │ properties: {}
    ├─0 text "\n  "
    ├─1 text "List Item"
    └─2 text "\n"

Actual behavior

The li tag is still included:

root[1]
│ data: {"quirksMode":true}
└─0 element<div>[3]
    │ properties: {}
    ├─0 text "\n  "
    ├─1 element<li>[1]
    │   │ properties: {}
    │   └─0 text "List Item"
    └─2 text "\n"

I investigated a bit and it seems like this bug has appeared because of this: syntax-tree/hast-util-sanitize@19631bb#diff-92bbac9a308cd5fcf9db165841f2d90ce981baddcb2b1e26cfff170929af3bd1R252. I can create a PR for it if you want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    👀 no/externalThis makes more sense somewhere else

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions