Skip to content

Commit

Permalink
attribute-fixture: Render valid meta tags
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Feb 10, 2023
1 parent e88c04e commit 5f9e4ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
8 changes: 4 additions & 4 deletions fixtures/attribute-behavior/AttributeTableSnapshot.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## `about` (on `<div>` inside `<div>`)
## `about` (on `<div>` inside `<div>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `about=(string)`| (changed)| `"a string"` |
Expand Down Expand Up @@ -1998,7 +1998,7 @@
| `colSpan=(null)`| (initial, ssr error, ssr mismatch)| `<number: 1>` |
| `colSpan=(undefined)`| (initial, ssr error, ssr mismatch)| `<number: 1>` |

## `content` (on `<meta>` inside `<div>`)
## `content` (on `<meta>` inside `<head>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `content=(string)`| (changed)| `"a string"` |
Expand Down Expand Up @@ -5123,7 +5123,7 @@
| `htmlFor=(null)`| (initial)| `<empty string>` |
| `htmlFor=(undefined)`| (initial)| `<empty string>` |

## `http-equiv` (on `<meta>` inside `<div>`)
## `http-equiv` (on `<meta>` inside `<head>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `http-equiv=(string)`| (changed, warning)| `"a string"` |
Expand All @@ -5148,7 +5148,7 @@
| `http-equiv=(null)`| (initial, warning)| `<empty string>` |
| `http-equiv=(undefined)`| (initial, warning)| `<empty string>` |

## `httpEquiv` (on `<meta>` inside `<div>`)
## `httpEquiv` (on `<meta>` inside `<head>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `httpEquiv=(string)`| (changed)| `"a string"` |
Expand Down
8 changes: 8 additions & 0 deletions fixtures/attribute-behavior/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ function getRenderedAttributeValue(
return document.createElementNS('http://www.w3.org/2000/svg', 'svg');
} else if (containerTagName === 'document') {
return document.implementation.createHTMLDocument('');
} else if (containerTagName === 'head') {
return document.implementation.createHTMLDocument('').head;
} else {
return document.createElement(containerTagName);
}
Expand Down Expand Up @@ -308,6 +310,12 @@ function getRenderedAttributeValue(
);
container = createContainer();
container.innerHTML = html;
} else if (containerTagName === 'head') {
const html = serverRenderer.renderToString(
react.createElement(tagName, props)
);
container = createContainer();
container.innerHTML = html;
} else {
const html = serverRenderer.renderToString(
react.createElement(
Expand Down
16 changes: 13 additions & 3 deletions fixtures/attribute-behavior/src/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ const attributes = [
},
{name: 'cols', tagName: 'textarea'},
{name: 'colSpan', containerTagName: 'tr', tagName: 'td'},
{name: 'content', tagName: 'meta'},
{
name: 'content',
containerTagName: 'head',
tagName: 'meta',
extraProps: {name: 'description'},
},
{name: 'contentEditable'},
{
name: 'contentScriptType',
Expand Down Expand Up @@ -934,8 +939,13 @@ const attributes = [
{name: 'href', tagName: 'a', overrideStringValue: 'https://reactjs.com'},
{name: 'hrefLang', read: getAttribute('hreflang')},
{name: 'htmlFor', tagName: 'label'},
{name: 'http-equiv', tagName: 'meta', read: getProperty('httpEquiv')},
{name: 'httpEquiv', tagName: 'meta'},
{
name: 'http-equiv',
containerTagName: 'head',
tagName: 'meta',
read: getProperty('httpEquiv'),
},
{name: 'httpEquiv', containerTagName: 'head', tagName: 'meta'},
{name: 'icon', tagName: 'command', read: getAttribute('icon')},
{name: 'id'},
{name: 'ID', read: getProperty('id')},
Expand Down

0 comments on commit 5f9e4ff

Please sign in to comment.