Skip to content

Commit 1adecbe

Browse files
committed
attribute-fixture: Add special canonical default value for invalid props
E.g. for <meta name="description" /> cant be rendered in react@next without `content`.
1 parent 8a11322 commit 1adecbe

File tree

2 files changed

+69
-65
lines changed

2 files changed

+69
-65
lines changed

fixtures/attribute-behavior/AttributeTableSnapshot.md

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,27 +2001,27 @@
20012001
## `content` (on `<meta>` inside `<head>`)
20022002
| Test Case | Flags | Result |
20032003
| --- | --- | --- |
2004-
| `content=(string)`| (initial, error, ssr mismatch)| `` |
2005-
| `content=(empty string)`| (initial, error, ssr mismatch)| `` |
2006-
| `content=(array with string)`| (initial, error, ssr error)| `` |
2007-
| `content=(empty array)`| (initial, error, ssr error)| `` |
2008-
| `content=(object)`| (initial, error, ssr error)| `` |
2009-
| `content=(numeric string)`| (initial, error, ssr mismatch)| `` |
2010-
| `content=(-1)`| (initial, error, ssr error)| `` |
2011-
| `content=(0)`| (initial, error, ssr error)| `` |
2012-
| `content=(integer)`| (initial, error, ssr error)| `` |
2013-
| `content=(NaN)`| (initial, error, ssr error)| `` |
2014-
| `content=(float)`| (initial, error, ssr error)| `` |
2015-
| `content=(true)`| (initial, error, ssr error)| `` |
2016-
| `content=(false)`| (initial, error, ssr error)| `` |
2017-
| `content=(string 'true')`| (initial, error, ssr mismatch)| `` |
2018-
| `content=(string 'false')`| (initial, error, ssr mismatch)| `` |
2019-
| `content=(string 'on')`| (initial, error, ssr mismatch)| `` |
2020-
| `content=(string 'off')`| (initial, error, ssr mismatch)| `` |
2021-
| `content=(symbol)`| (initial, error, ssr error)| `` |
2022-
| `content=(function)`| (initial, error, ssr error)| `` |
2023-
| `content=(null)`| (initial, error, ssr error)| `` |
2024-
| `content=(undefined)`| (initial, error, ssr error)| `` |
2004+
| `content=(string)`| (changed)| `"a string"` |
2005+
| `content=(empty string)`| (changed)| `<empty string>` |
2006+
| `content=(array with string)`| (changed, error, ssr error)| `` |
2007+
| `content=(empty array)`| (changed, error, ssr error)| `` |
2008+
| `content=(object)`| (changed, error, ssr error)| `` |
2009+
| `content=(numeric string)`| (changed)| `"42"` |
2010+
| `content=(-1)`| (changed, error, ssr error)| `` |
2011+
| `content=(0)`| (changed, error, ssr error)| `` |
2012+
| `content=(integer)`| (changed, error, ssr error)| `` |
2013+
| `content=(NaN)`| (changed, error, ssr error)| `` |
2014+
| `content=(float)`| (changed, error, ssr error)| `` |
2015+
| `content=(true)`| (changed, error, ssr error)| `` |
2016+
| `content=(false)`| (changed, error, ssr error)| `` |
2017+
| `content=(string 'true')`| (changed)| `"true"` |
2018+
| `content=(string 'false')`| (changed)| `"false"` |
2019+
| `content=(string 'on')`| (changed)| `"on"` |
2020+
| `content=(string 'off')`| (changed)| `"off"` |
2021+
| `content=(symbol)`| (changed, error, ssr error)| `` |
2022+
| `content=(function)`| (changed, error, ssr error)| `` |
2023+
| `content=(null)`| (changed, error, ssr error)| `` |
2024+
| `content=(undefined)`| (changed, error, ssr error)| `` |
20252025

20262026
## `contentEditable` (on `<div>` inside `<div>`)
20272027
| Test Case | Flags | Result |
@@ -5126,52 +5126,52 @@
51265126
## `http-equiv` (on `<meta>` inside `<head>`)
51275127
| Test Case | Flags | Result |
51285128
| --- | --- | --- |
5129-
| `http-equiv=(string)`| (initial, error, ssr error)| `` |
5130-
| `http-equiv=(empty string)`| (initial, error, ssr error)| `` |
5131-
| `http-equiv=(array with string)`| (initial, error, ssr error)| `` |
5132-
| `http-equiv=(empty array)`| (initial, error, ssr error)| `` |
5133-
| `http-equiv=(object)`| (initial, error, ssr error)| `` |
5134-
| `http-equiv=(numeric string)`| (initial, error, ssr error)| `` |
5135-
| `http-equiv=(-1)`| (initial, error, ssr error)| `` |
5136-
| `http-equiv=(0)`| (initial, error, ssr error)| `` |
5137-
| `http-equiv=(integer)`| (initial, error, ssr error)| `` |
5138-
| `http-equiv=(NaN)`| (initial, error, ssr error)| `` |
5139-
| `http-equiv=(float)`| (initial, error, ssr error)| `` |
5140-
| `http-equiv=(true)`| (initial, error, ssr error)| `` |
5141-
| `http-equiv=(false)`| (initial, error, ssr error)| `` |
5142-
| `http-equiv=(string 'true')`| (initial, error, ssr error)| `` |
5143-
| `http-equiv=(string 'false')`| (initial, error, ssr error)| `` |
5144-
| `http-equiv=(string 'on')`| (initial, error, ssr error)| `` |
5145-
| `http-equiv=(string 'off')`| (initial, error, ssr error)| `` |
5146-
| `http-equiv=(symbol)`| (initial, error, ssr error)| `` |
5147-
| `http-equiv=(function)`| (initial, error, ssr error)| `` |
5148-
| `http-equiv=(null)`| (initial, error, ssr error)| `` |
5149-
| `http-equiv=(undefined)`| (initial, error, ssr error)| `` |
5129+
| `http-equiv=(string)`| (changed, error, ssr error)| `` |
5130+
| `http-equiv=(empty string)`| (changed, error, ssr error)| `` |
5131+
| `http-equiv=(array with string)`| (changed, error, ssr error)| `` |
5132+
| `http-equiv=(empty array)`| (changed, error, ssr error)| `` |
5133+
| `http-equiv=(object)`| (changed, error, ssr error)| `` |
5134+
| `http-equiv=(numeric string)`| (changed, error, ssr error)| `` |
5135+
| `http-equiv=(-1)`| (changed, error, ssr error)| `` |
5136+
| `http-equiv=(0)`| (changed, error, ssr error)| `` |
5137+
| `http-equiv=(integer)`| (changed, error, ssr error)| `` |
5138+
| `http-equiv=(NaN)`| (changed, error, ssr error)| `` |
5139+
| `http-equiv=(float)`| (changed, error, ssr error)| `` |
5140+
| `http-equiv=(true)`| (changed, error, ssr error)| `` |
5141+
| `http-equiv=(false)`| (changed, error, ssr error)| `` |
5142+
| `http-equiv=(string 'true')`| (changed, error, ssr error)| `` |
5143+
| `http-equiv=(string 'false')`| (changed, error, ssr error)| `` |
5144+
| `http-equiv=(string 'on')`| (changed, error, ssr error)| `` |
5145+
| `http-equiv=(string 'off')`| (changed, error, ssr error)| `` |
5146+
| `http-equiv=(symbol)`| (changed, error, ssr error)| `` |
5147+
| `http-equiv=(function)`| (changed, error, ssr error)| `` |
5148+
| `http-equiv=(null)`| (changed, error, ssr error)| `` |
5149+
| `http-equiv=(undefined)`| (changed, error, ssr error)| `` |
51505150

51515151
## `httpEquiv` (on `<meta>` inside `<head>`)
51525152
| Test Case | Flags | Result |
51535153
| --- | --- | --- |
5154-
| `httpEquiv=(string)`| (initial, error, ssr error)| `` |
5155-
| `httpEquiv=(empty string)`| (initial, error, ssr error)| `` |
5156-
| `httpEquiv=(array with string)`| (initial, error, ssr error)| `` |
5157-
| `httpEquiv=(empty array)`| (initial, error, ssr error)| `` |
5158-
| `httpEquiv=(object)`| (initial, error, ssr error)| `` |
5159-
| `httpEquiv=(numeric string)`| (initial, error, ssr error)| `` |
5160-
| `httpEquiv=(-1)`| (initial, error, ssr error)| `` |
5161-
| `httpEquiv=(0)`| (initial, error, ssr error)| `` |
5162-
| `httpEquiv=(integer)`| (initial, error, ssr error)| `` |
5163-
| `httpEquiv=(NaN)`| (initial, error, ssr error)| `` |
5164-
| `httpEquiv=(float)`| (initial, error, ssr error)| `` |
5165-
| `httpEquiv=(true)`| (initial, error, ssr error)| `` |
5166-
| `httpEquiv=(false)`| (initial, error, ssr error)| `` |
5167-
| `httpEquiv=(string 'true')`| (initial, error, ssr error)| `` |
5168-
| `httpEquiv=(string 'false')`| (initial, error, ssr error)| `` |
5169-
| `httpEquiv=(string 'on')`| (initial, error, ssr error)| `` |
5170-
| `httpEquiv=(string 'off')`| (initial, error, ssr error)| `` |
5171-
| `httpEquiv=(symbol)`| (initial, error, ssr error)| `` |
5172-
| `httpEquiv=(function)`| (initial, error, ssr error)| `` |
5173-
| `httpEquiv=(null)`| (initial, error, ssr error)| `` |
5174-
| `httpEquiv=(undefined)`| (initial, error, ssr error)| `` |
5154+
| `httpEquiv=(string)`| (changed, error, ssr error)| `` |
5155+
| `httpEquiv=(empty string)`| (changed, error, ssr error)| `` |
5156+
| `httpEquiv=(array with string)`| (changed, error, ssr error)| `` |
5157+
| `httpEquiv=(empty array)`| (changed, error, ssr error)| `` |
5158+
| `httpEquiv=(object)`| (changed, error, ssr error)| `` |
5159+
| `httpEquiv=(numeric string)`| (changed, error, ssr error)| `` |
5160+
| `httpEquiv=(-1)`| (changed, error, ssr error)| `` |
5161+
| `httpEquiv=(0)`| (changed, error, ssr error)| `` |
5162+
| `httpEquiv=(integer)`| (changed, error, ssr error)| `` |
5163+
| `httpEquiv=(NaN)`| (changed, error, ssr error)| `` |
5164+
| `httpEquiv=(float)`| (changed, error, ssr error)| `` |
5165+
| `httpEquiv=(true)`| (changed, error, ssr error)| `` |
5166+
| `httpEquiv=(false)`| (changed, error, ssr error)| `` |
5167+
| `httpEquiv=(string 'true')`| (changed, error, ssr error)| `` |
5168+
| `httpEquiv=(string 'false')`| (changed, error, ssr error)| `` |
5169+
| `httpEquiv=(string 'on')`| (changed, error, ssr error)| `` |
5170+
| `httpEquiv=(string 'off')`| (changed, error, ssr error)| `` |
5171+
| `httpEquiv=(symbol)`| (changed, error, ssr error)| `` |
5172+
| `httpEquiv=(function)`| (changed, error, ssr error)| `` |
5173+
| `httpEquiv=(null)`| (changed, error, ssr error)| `` |
5174+
| `httpEquiv=(undefined)`| (changed, error, ssr error)| `` |
51755175

51765176
## `icon` (on `<command>` inside `<div>`)
51775177
| Test Case | Flags | Result |

fixtures/attribute-behavior/src/App.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,12 @@ function getRenderedAttributeValue(
284284
try {
285285
let container = createContainer();
286286
renderer.render(react.createElement(tagName, baseProps), container);
287-
defaultValue = read(container.firstChild);
288-
canonicalDefaultValue = getCanonicalizedValue(defaultValue);
287+
try {
288+
defaultValue = read(container.firstChild);
289+
canonicalDefaultValue = getCanonicalizedValue(defaultValue);
290+
} catch (error) {
291+
canonicalDefaultValue = '<invalid>';
292+
}
289293

290294
container = createContainer();
291295
renderer.render(react.createElement(tagName, props), container);

0 commit comments

Comments
 (0)