Commit 47ba6739 authored by David Sveningsson's avatar David Sveningsson
Browse files

fix(elements): add `<details>` and `<summary>` elements

fixes #89
parent d17fd6e6
Pipeline #146203499 passed with stages
in 9 minutes and 38 seconds
......@@ -1432,6 +1432,75 @@ Array [
exports[`HTML elements <del> valid markup 1`] = `Array []`;
exports[`HTML elements <details> invalid markup 1`] = `
Array [
Object {
"errorCount": 3,
"filePath": "test-files/elements/details-invalid.html",
"messages": Array [
Object {
"column": 3,
"context": undefined,
"line": 4,
"message": "Element <summary> must be used before <div> in this context",
"offset": 62,
"ruleId": "element-permitted-order",
"selector": "details:nth-child(1) > summary",
"severity": 2,
"size": 7,
},
Object {
"column": 2,
"context": Object {
"missing": "summary",
"node": "details",
},
"line": 8,
"message": "<details> element must have <summary> as content",
"offset": 123,
"ruleId": "element-required-content",
"selector": "details:nth-child(2)",
"severity": 2,
"size": 7,
},
Object {
"column": 16,
"context": Object {
"allowed": Array [],
"attribute": "open",
"element": "details",
"value": "foobar",
},
"line": 11,
"message": "Attribute \\"open\\" has invalid value \\"foobar\\"",
"offset": 193,
"ruleId": "attribute-allowed-values",
"selector": "details:nth-child(3)",
"severity": 2,
"size": 6,
},
],
"source": "<!-- summary must go before flow -->
<details>
<div></div>
<summary></summary>
</details>
<!-- summary is required -->
<details></details>
<!-- open attribute is boolean -->
<details open=\\"foobar\\">
<summary></summary>
</details>
",
"warningCount": 0,
},
]
`;
exports[`HTML elements <details> valid markup 1`] = `Array []`;
exports[`HTML elements <dfn> invalid markup 1`] = `
Array [
Object {
......@@ -5368,6 +5437,54 @@ Array [
exports[`HTML elements <sub> valid markup 1`] = `Array []`;
exports[`HTML elements <summary> invalid markup 1`] = `
Array [
Object {
"errorCount": 2,
"filePath": "test-files/elements/summary-invalid.html",
"messages": Array [
Object {
"column": 3,
"context": undefined,
"line": 3,
"message": "Element <summary> is not permitted as content in <div>",
"offset": 58,
"ruleId": "element-permitted-content",
"selector": "div > summary",
"severity": 2,
"size": 7,
},
Object {
"column": 4,
"context": undefined,
"line": 9,
"message": "Element <p> is not permitted as content in <summary>",
"offset": 159,
"ruleId": "element-permitted-content",
"selector": "details > summary > p",
"severity": 2,
"size": 1,
},
],
"source": "<!-- should not allow under arbitrary content -->
<div>
<summary>lorem ipsum</summary>
</div>
<!-- should not allow flow content -->
<details>
<summary>
<p>lorem ipsum</p>
</summary>
</details>
",
"warningCount": 0,
},
]
`;
exports[`HTML elements <summary> valid markup 1`] = `Array []`;
exports[`HTML elements <sup> invalid markup 1`] = `
Array [
Object {
......
......@@ -272,6 +272,18 @@
"transparent": true
},
"details": {
"flow": true,
"sectioning": true,
"interactive": true,
"attributes": {
"open": []
},
"permittedContent": ["summary", "@flow"],
"permittedOrder": ["summary", "@flow"],
"requiredContent": ["summary"]
},
"dfn": {
"flow": true,
"phrasing": true,
......@@ -1014,6 +1026,10 @@
"permittedContent": ["@phrasing"]
},
"summary": {
"permittedContent": ["@phrasing", "@heading"]
},
"sup": {
"flow": true,
"phrasing": true,
......
......@@ -35,6 +35,7 @@ const tagNames = [
"datalist",
"dd",
"del",
"details",
"dfn",
"dir",
"div",
......@@ -119,6 +120,7 @@ const tagNames = [
"strong",
"style",
"sub",
"summary",
"sup",
"svg",
"table",
......
<!-- summary must go before flow -->
<details>
<div></div>
<summary></summary>
</details>
<!-- summary is required -->
<details></details>
<!-- open attribute is boolean -->
<details open="foobar">
<summary></summary>
</details>
<!-- should allow in flow -->
<div>
<details><summary></summary></details>
</div>
<!-- should allow flow after summary -->
<details>
<summary>lorem ipsum</summary>
<div>dolor sit amet</div>
</details>
<!-- should allow open boolean attribute -->
<details open>
<summary></summary>
</details>
<!-- should not allow under arbitrary content -->
<div>
<summary>lorem ipsum</summary>
</div>
<!-- should not allow flow content -->
<details>
<summary>
<p>lorem ipsum</p>
</summary>
</details>
<!-- should allow summary under details -->
<details>
<summary>Lorem ipsum</summary>
</details>
<!-- should allow phrasing and heading -->
<details>
<summary>
<span>lorem</span> <h1>ipsum</h1>
</summary>
</details>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment