From cb4f9e397bfbeef62c81e4bfc1c9b2e1256bf2e7 Mon Sep 17 00:00:00 2001 From: GL502VS Date: Mon, 16 Jun 2025 21:50:42 +0200 Subject: [PATCH] more customizable select support --- src/mapping.js | 4 ++-- tests/validation.test.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mapping.js b/src/mapping.js index 2695038..a889832 100644 --- a/src/mapping.js +++ b/src/mapping.js @@ -18,7 +18,7 @@ const onlyValidChildren = { 'template', ]), optgroup: new Set(['option']), - select: new Set(['optgroup', 'option', 'hr', 'button']), + select: new Set(['optgroup', 'option', 'hr', 'button', 'div']), math: new Set(['mrow']), script: new Set(), // table @@ -30,7 +30,7 @@ const onlyValidChildren = { tfoot: new Set(['tr']), // these elements can not have any children elements iframe: emptySet, - option: emptySet, + option: new Set(['abbr', 'b', 'bdi', 'bdo', 'br', 'canvas', 'cite', 'code', 'data', 'del', 'dfn', 'div', 'em', 'i', 'img', 'ins', 'kbd', 'link', 'mark', 'meter', 'noscript', 'output', 'picture', 'progress', 'q', 'ruby', 's', 'samp', 'script', 'small', 'span', 'strong', 'sub', 'sup', 'template', 'time', 'u', 'var', 'wbr']), textarea: emptySet, style: emptySet, title: emptySet, diff --git a/tests/validation.test.js b/tests/validation.test.js index 70c5bed..7ac93eb 100644 --- a/tests/validation.test.js +++ b/tests/validation.test.js @@ -24,6 +24,7 @@ test('select', () => { expect(isValidHTMLNesting('select', 'optgroup')).toBe(true); expect(isValidHTMLNesting('select', 'hr')).toBe(true); expect(isValidHTMLNesting('select', 'button')).toBe(true); + expect(isValidHTMLNesting('select', 'div')).toBe(true); }); test('p', () => {