[go: up one dir, main page]

Skip to content

element-required-ancestor errors wrongly for element inside <template> tags

The element-required-ancestor rule should allow a <template> tag to contain elements that require specific ancestors without their ancestor being present inside the template's content.

Reduced test-case

<dt> and <dd> elements need a dl as their ancestor, unless they're inside a <template> (for example if the definition list is build dynamically using JavaScript). The following HTML code, however triggers an error

<dl href="">
</dl>
<template>
  <dt></dt>
  <dd></dd>
</template>

Configuration

{
  "extends": ["html-validate:recommended"]
}

Expected result

No errors

Actual result

html-validate outputs the following errors:

4:4  error  <dt> element requires a "dl > dt" or "dl > div > dt" ancestor  element-required-ancestor
5:4  error  <dd> element requires a "dl > dd" or "dl > div > dd" ancestor  element-required-ancestor

Version

  • html-validate: 9.5.2