Commit c271a044 authored by David Sveningsson's avatar David Sveningsson
Browse files

feat(meta): new property `scriptSupporting`

parent 22a10ab3
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ export interface MetaElement {
  foreign: boolean;
  void: boolean;
  transparent: boolean;
  scriptSupporting: boolean;

  /* attributes */
  deprecatedAttributes: string[];
@@ -130,6 +131,15 @@ as a child of a `<span>` element (phrasing) it only allows new phrasing content.
For custom elements it can be useful to set this if the content category isn't
flow.

### `scriptSupporting`

Elements whose primary purpose is to support scripting should set this flag to `true`.
Some elements will generally only allow a very narrow set of children (such as `<ul>` only allowing `<li>`) but usually also allows [script-supporting elements][whatwg-scriptsupporting].

In HTML5 both the `<script>` and `<template>` tags are considered script-supporting but javascript frameworks and web-components may include additional tags.

[whatwg-scriptsupporting]: https://html.spec.whatwg.org/multipage/dom.html#script-supporting-elements-2

## Permitted content

### `attributes`
+15 −15
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@
  "dl": {
    "flow": true,
    "deprecatedAttributes": ["compact"],
    "permittedContent": ["dt", "dd", "div", "script", "template"]
    "permittedContent": ["@script", "dt", "dd", "div"]
  },

  "dt": {
@@ -712,7 +712,7 @@
      "type": ["a", "A", "i", "I", "1"]
    },
    "deprecatedAttributes": ["compact"],
    "permittedContent": ["li", "script", "template"]
    "permittedContent": ["@script", "li"]
  },

  "optgroup": {
@@ -720,7 +720,7 @@
    "attributes": {
      "disabled": []
    },
    "permittedContent": ["option", "script", "template"]
    "permittedContent": ["@script", "option"]
  },

  "option": {
@@ -782,7 +782,7 @@
    "flow": true,
    "phrasing": true,
    "embedded": true,
    "permittedContent": ["source", "img", "script", "template"],
    "permittedContent": ["@script", "source", "img"],
    "permittedOrder": ["source", "img"]
  },

@@ -851,6 +851,7 @@
    "metadata": true,
    "flow": true,
    "phrasing": true,
    "scriptSupporting": true,
    "attributes": {
      "async": [],
      "crossorigin": ["", "anonymous", "use-credentials"],
@@ -880,13 +881,12 @@
      "size": ["/\\d+/"]
    },
    "permittedContent": [
      "@script",
      "datasrc",
      "datafld",
      "dataformatas",
      "option",
      "optgroup",
      "script",
      "template"
      "optgroup"
    ]
  },

@@ -969,11 +969,10 @@
      "width"
    ],
    "permittedContent": [
      "@script",
      "caption?",
      "colgroup",
      "script",
      "tbody",
      "template",
      "tfoot?",
      "thead?",
      "tr"
@@ -990,7 +989,7 @@
      "charoff",
      "valign"
    ],
    "permittedContent": ["tr", "script", "template"]
    "permittedContent": ["@script", "tr"]
  },

  "td": {
@@ -1019,7 +1018,8 @@
  "template": {
    "metadata": true,
    "flow": true,
    "phrasing": true
    "phrasing": true,
    "scriptSupporting": true
  },

  "textarea": {
@@ -1052,7 +1052,7 @@
      "charoff",
      "valign"
    ],
    "permittedContent": ["tr", "script", "template"]
    "permittedContent": ["@script", "tr"]
  },

  "th": {
@@ -1091,7 +1091,7 @@
      "charoff",
      "valign"
    ],
    "permittedContent": ["tr", "script", "template"]
    "permittedContent": ["@script", "tr"]
  },

  "time": {
@@ -1115,7 +1115,7 @@
      "charoff",
      "valign"
    ],
    "permittedContent": ["td", "th", "script", "template"]
    "permittedContent": ["@script", "td", "th"]
  },

  "track": {
@@ -1135,7 +1135,7 @@
  "ul": {
    "flow": true,
    "deprecatedAttributes": ["compact", "type"],
    "permittedContent": ["li", "script", "template"]
    "permittedContent": ["@script", "li"]
  },

  "var": {
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
        "void": { "type": "boolean" },
        "transparent": { "type": "boolean" },
        "implicitClosed": { "type": "array", "contains": { "type": "string" } },
        "scriptSupporting": { "type": "boolean" },

        "deprecatedAttributes": {
          "type": "array",
+1 −0
Original line number Diff line number Diff line
@@ -641,6 +641,7 @@ function mockEntry(stub = {}): MetaData {
			deprecated: false,
			void: false,
			transparent: false,
			scriptSupporting: false,
		},
		stub
	);
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ export interface MetaData {
	void: boolean;
	transparent: boolean;
	implicitClosed?: string[];
	scriptSupporting: boolean;

	/* attribute */
	deprecatedAttributes?: string[];
Loading