|
2 | 2 | * Map of elements that have certain elements that are not allowed inside them, in the sense that they will auto-close the parent/ancestor element.
|
3 | 3 | * Theoretically one could take advantage of it but most of the time it will just result in confusing behavior and break when SSR'd.
|
4 | 4 | * There are more elements that are invalid inside other elements, but they're not auto-closed and so don't break SSR and are therefore not listed here.
|
5 |
| - * @type {Record<string, { direct: string[]} | { descendant: string[]; resets?: string[] }>} |
| 5 | + * @type {Record<string, { direct: string[]} | { descendant: string[]; reset_by?: string[] }>} |
6 | 6 | */
|
7 | 7 | const autoclosing_children = {
|
8 | 8 | // based on http://developers.whatwg.org/syntax.html#syntax-tag-omission
|
9 | 9 | li: { direct: ['li'] },
|
10 | 10 | // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dt#technical_summary
|
11 |
| - dt: { descendant: ['dt', 'dd'], resets: ['dl'] }, |
12 |
| - dd: { descendant: ['dt', 'dd'], resets: ['dl'] }, |
| 11 | + dt: { descendant: ['dt', 'dd'], reset_by: ['dl'] }, |
| 12 | + dd: { descendant: ['dt', 'dd'], reset_by: ['dl'] }, |
13 | 13 | p: {
|
14 | 14 | descendant: [
|
15 | 15 | 'address',
|
@@ -76,7 +76,7 @@ export function closing_tag_omitted(current, next) {
|
76 | 76 | /**
|
77 | 77 | * Map of elements that have certain elements that are not allowed inside them, in the sense that the browser will somehow repair the HTML.
|
78 | 78 | * There are more elements that are invalid inside other elements, but they're not repaired and so don't break SSR and are therefore not listed here.
|
79 |
| - * @type {Record<string, { direct: string[]} | { descendant: string[]; resets?: string[]; only?: string[] } | { only: string[] }>} |
| 79 | + * @type {Record<string, { direct: string[]} | { descendant: string[]; reset_by?: string[]; only?: string[] } | { only: string[] }>} |
80 | 80 | */
|
81 | 81 | const disallowed_children = {
|
82 | 82 | ...autoclosing_children,
|
@@ -146,10 +146,10 @@ export function is_tag_valid_with_ancestor(tag, ancestors) {
|
146 | 146 | const disallowed = disallowed_children[target];
|
147 | 147 | if (!disallowed) return true;
|
148 | 148 |
|
149 |
| - if ('resets' in disallowed && disallowed.resets) { |
| 149 | + if ('reset_by' in disallowed && disallowed.reset_by) { |
150 | 150 | for (let i = ancestors.length - 2; i >= 0; i--) {
|
151 | 151 | // A reset means that forbidden descendants are allowed again
|
152 |
| - if (disallowed.resets.includes(ancestors[i])) { |
| 152 | + if (disallowed.reset_by.includes(ancestors[i])) { |
153 | 153 | return true;
|
154 | 154 | }
|
155 | 155 | }
|
|
0 commit comments