Skip to content

Commit 8a11322

Browse files
committed
attribute-fixture: Include tag mismatch in fixture result instead of throwing
1 parent bae9593 commit 8a11322

File tree

2 files changed

+74
-78
lines changed

2 files changed

+74
-78
lines changed

fixtures/attribute-behavior/AttributeTableSnapshot.md

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,30 +1998,30 @@
19981998
| `colSpan=(null)`| (initial, ssr error, ssr mismatch)| `<number: 1>` |
19991999
| `colSpan=(undefined)`| (initial, ssr error, ssr mismatch)| `<number: 1>` |
20002000

2001-
## `content` (on `<meta>` inside `<div>`)
2002-
| Test Case | Flags | Result |
2003-
| --- | --- | --- |
2004-
| `content=(string)`| (changed)| `"a string"` |
2005-
| `content=(empty string)`| (initial)| `<empty string>` |
2006-
| `content=(array with string)`| (changed)| `"string"` |
2007-
| `content=(empty array)`| (initial)| `<empty string>` |
2008-
| `content=(object)`| (changed)| `"result of toString()"` |
2009-
| `content=(numeric string)`| (changed)| `"42"` |
2010-
| `content=(-1)`| (changed)| `"-1"` |
2011-
| `content=(0)`| (changed)| `"0"` |
2012-
| `content=(integer)`| (changed)| `"1"` |
2013-
| `content=(NaN)`| (changed, warning)| `"NaN"` |
2014-
| `content=(float)`| (changed)| `"99.99"` |
2015-
| `content=(true)`| (initial, warning)| `<empty string>` |
2016-
| `content=(false)`| (initial, warning)| `<empty string>` |
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)`| (initial, warning)| `<empty string>` |
2022-
| `content=(function)`| (initial, warning)| `<empty string>` |
2023-
| `content=(null)`| (initial)| `<empty string>` |
2024-
| `content=(undefined)`| (initial)| `<empty string>` |
2001+
## `content` (on `<meta>` inside `<head>`)
2002+
| Test Case | Flags | Result |
2003+
| --- | --- | --- |
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)| `` |
20252025

20262026
## `contentEditable` (on `<div>` inside `<div>`)
20272027
| Test Case | Flags | Result |
@@ -5123,55 +5123,55 @@
51235123
| `htmlFor=(null)`| (initial)| `<empty string>` |
51245124
| `htmlFor=(undefined)`| (initial)| `<empty string>` |
51255125

5126-
## `http-equiv` (on `<meta>` inside `<div>`)
5127-
| Test Case | Flags | Result |
5128-
| --- | --- | --- |
5129-
| `http-equiv=(string)`| (changed, warning)| `"a string"` |
5130-
| `http-equiv=(empty string)`| (initial, warning)| `<empty string>` |
5131-
| `http-equiv=(array with string)`| (changed, warning)| `"string"` |
5132-
| `http-equiv=(empty array)`| (initial, warning)| `<empty string>` |
5133-
| `http-equiv=(object)`| (changed, warning)| `"result of toString()"` |
5134-
| `http-equiv=(numeric string)`| (changed, warning)| `"42"` |
5135-
| `http-equiv=(-1)`| (changed, warning)| `"-1"` |
5136-
| `http-equiv=(0)`| (changed, warning)| `"0"` |
5137-
| `http-equiv=(integer)`| (changed, warning)| `"1"` |
5138-
| `http-equiv=(NaN)`| (changed, warning)| `"NaN"` |
5139-
| `http-equiv=(float)`| (changed, warning)| `"99.99"` |
5140-
| `http-equiv=(true)`| (initial, warning)| `<empty string>` |
5141-
| `http-equiv=(false)`| (initial, warning)| `<empty string>` |
5142-
| `http-equiv=(string 'true')`| (changed, warning)| `"true"` |
5143-
| `http-equiv=(string 'false')`| (changed, warning)| `"false"` |
5144-
| `http-equiv=(string 'on')`| (changed, warning)| `"on"` |
5145-
| `http-equiv=(string 'off')`| (changed, warning)| `"off"` |
5146-
| `http-equiv=(symbol)`| (initial, warning)| `<empty string>` |
5147-
| `http-equiv=(function)`| (initial, warning)| `<empty string>` |
5148-
| `http-equiv=(null)`| (initial, warning)| `<empty string>` |
5149-
| `http-equiv=(undefined)`| (initial, warning)| `<empty string>` |
5150-
5151-
## `httpEquiv` (on `<meta>` inside `<div>`)
5152-
| Test Case | Flags | Result |
5153-
| --- | --- | --- |
5154-
| `httpEquiv=(string)`| (changed)| `"a string"` |
5155-
| `httpEquiv=(empty string)`| (initial)| `<empty string>` |
5156-
| `httpEquiv=(array with string)`| (changed)| `"string"` |
5157-
| `httpEquiv=(empty array)`| (initial)| `<empty string>` |
5158-
| `httpEquiv=(object)`| (changed)| `"result of toString()"` |
5159-
| `httpEquiv=(numeric string)`| (changed)| `"42"` |
5160-
| `httpEquiv=(-1)`| (changed)| `"-1"` |
5161-
| `httpEquiv=(0)`| (changed)| `"0"` |
5162-
| `httpEquiv=(integer)`| (changed)| `"1"` |
5163-
| `httpEquiv=(NaN)`| (changed, warning)| `"NaN"` |
5164-
| `httpEquiv=(float)`| (changed)| `"99.99"` |
5165-
| `httpEquiv=(true)`| (initial, warning)| `<empty string>` |
5166-
| `httpEquiv=(false)`| (initial, warning)| `<empty string>` |
5167-
| `httpEquiv=(string 'true')`| (changed)| `"true"` |
5168-
| `httpEquiv=(string 'false')`| (changed)| `"false"` |
5169-
| `httpEquiv=(string 'on')`| (changed)| `"on"` |
5170-
| `httpEquiv=(string 'off')`| (changed)| `"off"` |
5171-
| `httpEquiv=(symbol)`| (initial, warning)| `<empty string>` |
5172-
| `httpEquiv=(function)`| (initial, warning)| `<empty string>` |
5173-
| `httpEquiv=(null)`| (initial)| `<empty string>` |
5174-
| `httpEquiv=(undefined)`| (initial)| `<empty string>` |
5126+
## `http-equiv` (on `<meta>` inside `<head>`)
5127+
| Test Case | Flags | Result |
5128+
| --- | --- | --- |
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)| `` |
5150+
5151+
## `httpEquiv` (on `<meta>` inside `<head>`)
5152+
| Test Case | Flags | Result |
5153+
| --- | --- | --- |
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)| `` |
51755175

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

fixtures/attribute-behavior/src/App.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ function getRenderedAttributeValue(
300300
}
301301

302302
_didWarn = false;
303-
let hasTagMismatch = false;
304303
let hasUnknownElement = false;
305304
try {
306305
let container;
@@ -333,7 +332,7 @@ function getRenderedAttributeValue(
333332
!container.lastChild ||
334333
container.lastChild.tagName.toLowerCase() !== tagName.toLowerCase()
335334
) {
336-
hasTagMismatch = true;
335+
throw new Error('Tag mismatch. Expected: ' + tagName);
337336
}
338337

339338
if (
@@ -355,9 +354,6 @@ function getRenderedAttributeValue(
355354

356355
console.error = originalConsoleError;
357356

358-
if (hasTagMismatch) {
359-
throw new Error('Tag mismatch. Expected: ' + tagName);
360-
}
361357
if (hasUnknownElement) {
362358
throw new Error('Unexpected unknown element: ' + tagName);
363359
}

0 commit comments

Comments
 (0)