From ab714670bfccc1160303690328a1def1d72f7c6e Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 10 Feb 2023 14:00:28 +0100 Subject: [PATCH 1/6] Update attribute-behavior snapshot (except ) Ran without `` tags which currently crash the fixture --- .../AttributeTableSnapshot.md | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/fixtures/attribute-behavior/AttributeTableSnapshot.md b/fixtures/attribute-behavior/AttributeTableSnapshot.md index 559a82fa4fa05..c4cc94f8d9ac9 100644 --- a/fixtures/attribute-behavior/AttributeTableSnapshot.md +++ b/fixtures/attribute-behavior/AttributeTableSnapshot.md @@ -12251,27 +12251,27 @@ ## `version` (on `` inside ``) | Test Case | Flags | Result | | --- | --- | --- | -| `version=(string)`| (changed, ssr mismatch)| `"a string"` | -| `version=(empty string)`| (initial)| `` | -| `version=(array with string)`| (changed, ssr mismatch)| `"string"` | -| `version=(empty array)`| (initial)| `` | -| `version=(object)`| (changed, ssr mismatch)| `"result of toString()"` | -| `version=(numeric string)`| (changed, ssr mismatch)| `"42"` | -| `version=(-1)`| (changed, ssr mismatch)| `"-1"` | -| `version=(0)`| (changed, ssr mismatch)| `"0"` | -| `version=(integer)`| (changed, ssr mismatch)| `"1"` | -| `version=(NaN)`| (changed, warning, ssr mismatch)| `"NaN"` | -| `version=(float)`| (changed, ssr mismatch)| `"99.99"` | -| `version=(true)`| (initial, warning)| `` | -| `version=(false)`| (initial, warning)| `` | -| `version=(string 'true')`| (changed, ssr mismatch)| `"true"` | -| `version=(string 'false')`| (changed, ssr mismatch)| `"false"` | -| `version=(string 'on')`| (changed, ssr mismatch)| `"on"` | -| `version=(string 'off')`| (changed, ssr mismatch)| `"off"` | -| `version=(symbol)`| (initial, warning)| `` | -| `version=(function)`| (initial, warning)| `` | -| `version=(null)`| (initial)| `` | -| `version=(undefined)`| (initial)| `` | +| `version=(string)`| (initial, ssr mismatch)| `` | +| `version=(empty string)`| (initial, ssr mismatch)| `` | +| `version=(array with string)`| (initial, ssr mismatch)| `` | +| `version=(empty array)`| (initial, ssr mismatch)| `` | +| `version=(object)`| (initial, ssr mismatch)| `` | +| `version=(numeric string)`| (initial, ssr mismatch)| `` | +| `version=(-1)`| (initial, ssr mismatch)| `` | +| `version=(0)`| (initial, ssr mismatch)| `` | +| `version=(integer)`| (initial, ssr mismatch)| `` | +| `version=(NaN)`| (initial, warning, ssr mismatch)| `` | +| `version=(float)`| (initial, ssr mismatch)| `` | +| `version=(true)`| (initial, warning, ssr mismatch)| `` | +| `version=(false)`| (initial, warning, ssr mismatch)| `` | +| `version=(string 'true')`| (initial, ssr mismatch)| `` | +| `version=(string 'false')`| (initial, ssr mismatch)| `` | +| `version=(string 'on')`| (initial, ssr mismatch)| `` | +| `version=(string 'off')`| (initial, ssr mismatch)| `` | +| `version=(symbol)`| (initial, warning, ssr mismatch)| `` | +| `version=(function)`| (initial, warning, ssr mismatch)| `` | +| `version=(null)`| (initial, ssr mismatch)| `` | +| `version=(undefined)`| (initial, ssr mismatch)| `` | ## `version` (on `` inside `
`) | Test Case | Flags | Result | @@ -12526,23 +12526,23 @@ ## `viewTarget` (on `` inside ``) | Test Case | Flags | Result | | --- | --- | --- | -| `viewTarget=(string)`| (changed, ssr mismatch)| `"a string"` | -| `viewTarget=(empty string)`| (changed, ssr mismatch)| `` | -| `viewTarget=(array with string)`| (changed, ssr mismatch)| `"string"` | -| `viewTarget=(empty array)`| (changed, ssr mismatch)| `` | -| `viewTarget=(object)`| (changed, ssr mismatch)| `"result of toString()"` | -| `viewTarget=(numeric string)`| (changed, ssr mismatch)| `"42"` | -| `viewTarget=(-1)`| (changed, ssr mismatch)| `"-1"` | -| `viewTarget=(0)`| (changed, ssr mismatch)| `"0"` | -| `viewTarget=(integer)`| (changed, ssr mismatch)| `"1"` | -| `viewTarget=(NaN)`| (changed, warning, ssr mismatch)| `"NaN"` | -| `viewTarget=(float)`| (changed, ssr mismatch)| `"99.99"` | +| `viewTarget=(string)`| (changed)| `"a string"` | +| `viewTarget=(empty string)`| (changed)| `` | +| `viewTarget=(array with string)`| (changed)| `"string"` | +| `viewTarget=(empty array)`| (changed)| `` | +| `viewTarget=(object)`| (changed)| `"result of toString()"` | +| `viewTarget=(numeric string)`| (changed)| `"42"` | +| `viewTarget=(-1)`| (changed)| `"-1"` | +| `viewTarget=(0)`| (changed)| `"0"` | +| `viewTarget=(integer)`| (changed)| `"1"` | +| `viewTarget=(NaN)`| (changed, warning)| `"NaN"` | +| `viewTarget=(float)`| (changed)| `"99.99"` | | `viewTarget=(true)`| (initial, warning)| `` | | `viewTarget=(false)`| (initial, warning)| `` | -| `viewTarget=(string 'true')`| (changed, ssr mismatch)| `"true"` | -| `viewTarget=(string 'false')`| (changed, ssr mismatch)| `"false"` | -| `viewTarget=(string 'on')`| (changed, ssr mismatch)| `"on"` | -| `viewTarget=(string 'off')`| (changed, ssr mismatch)| `"off"` | +| `viewTarget=(string 'true')`| (changed)| `"true"` | +| `viewTarget=(string 'false')`| (changed)| `"false"` | +| `viewTarget=(string 'on')`| (changed)| `"on"` | +| `viewTarget=(string 'off')`| (changed)| `"off"` | | `viewTarget=(symbol)`| (initial, warning)| `` | | `viewTarget=(function)`| (initial, warning)| `` | | `viewTarget=(null)`| (initial)| `` | From d0032ab7d331fd9bce01a5236907b5087d583104 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 6 Feb 2023 10:39:34 +0100 Subject: [PATCH 2/6] Ensure Stable and Next have use same server impl --- fixtures/attribute-behavior/src/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixtures/attribute-behavior/src/App.js b/fixtures/attribute-behavior/src/App.js index 9307d6a2c81de..98194f76c79c7 100644 --- a/fixtures/attribute-behavior/src/App.js +++ b/fixtures/attribute-behavior/src/App.js @@ -764,7 +764,7 @@ class App extends React.Component { ReactDOMStable: 'https://unpkg.com/react-dom@latest/umd/react-dom.development.js', ReactDOMServerStable: - 'https://unpkg.com/react-dom@latest/umd/react-dom-server.browser.development.js', + 'https://unpkg.com/react-dom@latest/umd/react-dom-server-legacy.browser.development.js', ReactNext: '/react.development.js', ReactDOMNext: '/react-dom.development.js', ReactDOMServerNext: '/react-dom-server-legacy.browser.development.js', From 0de4cde53a8006728e6d54b5dbec49a9bf3454f8 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 6 Feb 2023 12:07:19 +0100 Subject: [PATCH 3/6] Render valid meta tags --- .../attribute-behavior/AttributeTableSnapshot.md | 8 ++++---- fixtures/attribute-behavior/src/App.js | 8 ++++++++ fixtures/attribute-behavior/src/attributes.js | 16 +++++++++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/fixtures/attribute-behavior/AttributeTableSnapshot.md b/fixtures/attribute-behavior/AttributeTableSnapshot.md index c4cc94f8d9ac9..ee01bc2a0d679 100644 --- a/fixtures/attribute-behavior/AttributeTableSnapshot.md +++ b/fixtures/attribute-behavior/AttributeTableSnapshot.md @@ -1,4 +1,4 @@ -## `about` (on `
` inside `
`) +## `about` (on `
` inside `
`) | Test Case | Flags | Result | | --- | --- | --- | | `about=(string)`| (changed)| `"a string"` | @@ -1998,7 +1998,7 @@ | `colSpan=(null)`| (initial, ssr error, ssr mismatch)| `` | | `colSpan=(undefined)`| (initial, ssr error, ssr mismatch)| `` | -## `content` (on `` inside `
`) +## `content` (on `` inside ``) | Test Case | Flags | Result | | --- | --- | --- | | `content=(string)`| (changed)| `"a string"` | @@ -5123,7 +5123,7 @@ | `htmlFor=(null)`| (initial)| `` | | `htmlFor=(undefined)`| (initial)| `` | -## `http-equiv` (on `` inside `
`) +## `http-equiv` (on `` inside ``) | Test Case | Flags | Result | | --- | --- | --- | | `http-equiv=(string)`| (changed, warning)| `"a string"` | @@ -5148,7 +5148,7 @@ | `http-equiv=(null)`| (initial, warning)| `` | | `http-equiv=(undefined)`| (initial, warning)| `` | -## `httpEquiv` (on `` inside `
`) +## `httpEquiv` (on `` inside ``) | Test Case | Flags | Result | | --- | --- | --- | | `httpEquiv=(string)`| (changed)| `"a string"` | diff --git a/fixtures/attribute-behavior/src/App.js b/fixtures/attribute-behavior/src/App.js index 98194f76c79c7..5f1bac46e4887 100644 --- a/fixtures/attribute-behavior/src/App.js +++ b/fixtures/attribute-behavior/src/App.js @@ -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); } @@ -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( diff --git a/fixtures/attribute-behavior/src/attributes.js b/fixtures/attribute-behavior/src/attributes.js index c0e5a133f1dce..3f90bfa9409d8 100644 --- a/fixtures/attribute-behavior/src/attributes.js +++ b/fixtures/attribute-behavior/src/attributes.js @@ -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', @@ -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')}, From 587810d4ee1d7ecd1bf4b09e840b10ff75436fa7 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 10 Feb 2023 14:10:20 +0100 Subject: [PATCH 4/6] Verify html[version] result by adding html[lang] `version` is obsolete so I was hoping this result doesn't matter. But `lang` has the same behavior i.e. isn't added to the DOM on the client --- .../AttributeTableSnapshot.md | 25 +++++++++++++++++++ fixtures/attribute-behavior/src/attributes.js | 1 + 2 files changed, 26 insertions(+) diff --git a/fixtures/attribute-behavior/AttributeTableSnapshot.md b/fixtures/attribute-behavior/AttributeTableSnapshot.md index ee01bc2a0d679..6a605155afca6 100644 --- a/fixtures/attribute-behavior/AttributeTableSnapshot.md +++ b/fixtures/attribute-behavior/AttributeTableSnapshot.md @@ -6198,6 +6198,31 @@ | `lang=(null)`| (initial)| `` | | `lang=(undefined)`| (initial)| `` | +## `lang` (on `` inside ``) +| Test Case | Flags | Result | +| --- | --- | --- | +| `lang=(string)`| (initial, ssr mismatch)| `` | +| `lang=(empty string)`| (initial, ssr mismatch)| `` | +| `lang=(array with string)`| (initial, ssr mismatch)| `` | +| `lang=(empty array)`| (initial, ssr mismatch)| `` | +| `lang=(object)`| (initial, ssr mismatch)| `` | +| `lang=(numeric string)`| (initial, ssr mismatch)| `` | +| `lang=(-1)`| (initial, ssr mismatch)| `` | +| `lang=(0)`| (initial, ssr mismatch)| `` | +| `lang=(integer)`| (initial, ssr mismatch)| `` | +| `lang=(NaN)`| (initial, warning, ssr mismatch)| `` | +| `lang=(float)`| (initial, ssr mismatch)| `` | +| `lang=(true)`| (initial, warning, ssr mismatch)| `` | +| `lang=(false)`| (initial, warning, ssr mismatch)| `` | +| `lang=(string 'true')`| (initial, ssr mismatch)| `` | +| `lang=(string 'false')`| (initial, ssr mismatch)| `` | +| `lang=(string 'on')`| (initial, ssr mismatch)| `` | +| `lang=(string 'off')`| (initial, ssr mismatch)| `` | +| `lang=(symbol)`| (initial, warning, ssr mismatch)| `` | +| `lang=(function)`| (initial, warning, ssr mismatch)| `` | +| `lang=(null)`| (initial, ssr mismatch)| `` | +| `lang=(undefined)`| (initial, ssr mismatch)| `` | + ## `length` (on `
` inside `
`) | Test Case | Flags | Result | | --- | --- | --- | diff --git a/fixtures/attribute-behavior/src/attributes.js b/fixtures/attribute-behavior/src/attributes.js index 3f90bfa9409d8..6222dcc9a099f 100644 --- a/fixtures/attribute-behavior/src/attributes.js +++ b/fixtures/attribute-behavior/src/attributes.js @@ -1086,6 +1086,7 @@ const attributes = [ {name: 'label', tagName: 'track'}, {name: 'LANG', read: getProperty('lang')}, {name: 'lang'}, + {name: 'lang', containerTagName: 'document', tagName: 'html'}, {name: 'length', read: getAttribute('length')}, { name: 'lengthAdjust', From 9a2f7f76f0a2772ebd149cd773f1ec81abb0e9b1 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 10 Feb 2023 14:29:33 +0100 Subject: [PATCH 5/6] Ensure we find the rendered element if we render into document --- .../AttributeTableSnapshot.md | 84 +++++++++---------- fixtures/attribute-behavior/src/App.js | 4 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/fixtures/attribute-behavior/AttributeTableSnapshot.md b/fixtures/attribute-behavior/AttributeTableSnapshot.md index 6a605155afca6..89e126ba234cf 100644 --- a/fixtures/attribute-behavior/AttributeTableSnapshot.md +++ b/fixtures/attribute-behavior/AttributeTableSnapshot.md @@ -6201,27 +6201,27 @@ ## `lang` (on `` inside ``) | Test Case | Flags | Result | | --- | --- | --- | -| `lang=(string)`| (initial, ssr mismatch)| `` | -| `lang=(empty string)`| (initial, ssr mismatch)| `` | -| `lang=(array with string)`| (initial, ssr mismatch)| `` | -| `lang=(empty array)`| (initial, ssr mismatch)| `` | -| `lang=(object)`| (initial, ssr mismatch)| `` | -| `lang=(numeric string)`| (initial, ssr mismatch)| `` | -| `lang=(-1)`| (initial, ssr mismatch)| `` | -| `lang=(0)`| (initial, ssr mismatch)| `` | -| `lang=(integer)`| (initial, ssr mismatch)| `` | -| `lang=(NaN)`| (initial, warning, ssr mismatch)| `` | -| `lang=(float)`| (initial, ssr mismatch)| `` | -| `lang=(true)`| (initial, warning, ssr mismatch)| `` | -| `lang=(false)`| (initial, warning, ssr mismatch)| `` | -| `lang=(string 'true')`| (initial, ssr mismatch)| `` | -| `lang=(string 'false')`| (initial, ssr mismatch)| `` | -| `lang=(string 'on')`| (initial, ssr mismatch)| `` | -| `lang=(string 'off')`| (initial, ssr mismatch)| `` | -| `lang=(symbol)`| (initial, warning, ssr mismatch)| `` | -| `lang=(function)`| (initial, warning, ssr mismatch)| `` | -| `lang=(null)`| (initial, ssr mismatch)| `` | -| `lang=(undefined)`| (initial, ssr mismatch)| `` | +| `lang=(string)`| (changed, ssr mismatch)| `"a string"` | +| `lang=(empty string)`| (initial)| `` | +| `lang=(array with string)`| (changed, ssr mismatch)| `"string"` | +| `lang=(empty array)`| (initial)| `` | +| `lang=(object)`| (changed, ssr mismatch)| `"result of toString()"` | +| `lang=(numeric string)`| (changed, ssr mismatch)| `"42"` | +| `lang=(-1)`| (changed, ssr mismatch)| `"-1"` | +| `lang=(0)`| (changed, ssr mismatch)| `"0"` | +| `lang=(integer)`| (changed, ssr mismatch)| `"1"` | +| `lang=(NaN)`| (changed, warning, ssr mismatch)| `"NaN"` | +| `lang=(float)`| (changed, ssr mismatch)| `"99.99"` | +| `lang=(true)`| (initial, warning)| `` | +| `lang=(false)`| (initial, warning)| `` | +| `lang=(string 'true')`| (changed, ssr mismatch)| `"true"` | +| `lang=(string 'false')`| (changed, ssr mismatch)| `"false"` | +| `lang=(string 'on')`| (changed, ssr mismatch)| `"on"` | +| `lang=(string 'off')`| (changed, ssr mismatch)| `"off"` | +| `lang=(symbol)`| (initial, warning)| `` | +| `lang=(function)`| (initial, warning)| `` | +| `lang=(null)`| (initial)| `` | +| `lang=(undefined)`| (initial)| `` | ## `length` (on `
` inside `
`) | Test Case | Flags | Result | @@ -12276,27 +12276,27 @@ ## `version` (on `` inside ``) | Test Case | Flags | Result | | --- | --- | --- | -| `version=(string)`| (initial, ssr mismatch)| `` | -| `version=(empty string)`| (initial, ssr mismatch)| `` | -| `version=(array with string)`| (initial, ssr mismatch)| `` | -| `version=(empty array)`| (initial, ssr mismatch)| `` | -| `version=(object)`| (initial, ssr mismatch)| `` | -| `version=(numeric string)`| (initial, ssr mismatch)| `` | -| `version=(-1)`| (initial, ssr mismatch)| `` | -| `version=(0)`| (initial, ssr mismatch)| `` | -| `version=(integer)`| (initial, ssr mismatch)| `` | -| `version=(NaN)`| (initial, warning, ssr mismatch)| `` | -| `version=(float)`| (initial, ssr mismatch)| `` | -| `version=(true)`| (initial, warning, ssr mismatch)| `` | -| `version=(false)`| (initial, warning, ssr mismatch)| `` | -| `version=(string 'true')`| (initial, ssr mismatch)| `` | -| `version=(string 'false')`| (initial, ssr mismatch)| `` | -| `version=(string 'on')`| (initial, ssr mismatch)| `` | -| `version=(string 'off')`| (initial, ssr mismatch)| `` | -| `version=(symbol)`| (initial, warning, ssr mismatch)| `` | -| `version=(function)`| (initial, warning, ssr mismatch)| `` | -| `version=(null)`| (initial, ssr mismatch)| `` | -| `version=(undefined)`| (initial, ssr mismatch)| `` | +| `version=(string)`| (changed, ssr mismatch)| `"a string"` | +| `version=(empty string)`| (initial)| `` | +| `version=(array with string)`| (changed, ssr mismatch)| `"string"` | +| `version=(empty array)`| (initial)| `` | +| `version=(object)`| (changed, ssr mismatch)| `"result of toString()"` | +| `version=(numeric string)`| (changed, ssr mismatch)| `"42"` | +| `version=(-1)`| (changed, ssr mismatch)| `"-1"` | +| `version=(0)`| (changed, ssr mismatch)| `"0"` | +| `version=(integer)`| (changed, ssr mismatch)| `"1"` | +| `version=(NaN)`| (changed, warning, ssr mismatch)| `"NaN"` | +| `version=(float)`| (changed, ssr mismatch)| `"99.99"` | +| `version=(true)`| (initial, warning)| `` | +| `version=(false)`| (initial, warning)| `` | +| `version=(string 'true')`| (changed, ssr mismatch)| `"true"` | +| `version=(string 'false')`| (changed, ssr mismatch)| `"false"` | +| `version=(string 'on')`| (changed, ssr mismatch)| `"on"` | +| `version=(string 'off')`| (changed, ssr mismatch)| `"off"` | +| `version=(symbol)`| (initial, warning)| `` | +| `version=(function)`| (initial, warning)| `` | +| `version=(null)`| (initial)| `` | +| `version=(undefined)`| (initial)| `` | ## `version` (on `` inside `
`) | Test Case | Flags | Result | diff --git a/fixtures/attribute-behavior/src/App.js b/fixtures/attribute-behavior/src/App.js index 5f1bac46e4887..db77eba907c5a 100644 --- a/fixtures/attribute-behavior/src/App.js +++ b/fixtures/attribute-behavior/src/App.js @@ -284,12 +284,12 @@ function getRenderedAttributeValue( try { let container = createContainer(); renderer.render(react.createElement(tagName, baseProps), container); - defaultValue = read(container.firstChild); + defaultValue = read(container.lastChild); canonicalDefaultValue = getCanonicalizedValue(defaultValue); container = createContainer(); renderer.render(react.createElement(tagName, props), container); - result = read(container.firstChild); + result = read(container.lastChild); canonicalResult = getCanonicalizedValue(result); didWarn = _didWarn; didError = false; From dfb5f2679e4c8710c0cc322302abc8c1c2d467f4 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 10 Feb 2023 16:50:09 +0100 Subject: [PATCH 6/6] Remove unnecessary `extraProps` --- fixtures/attribute-behavior/src/attributes.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fixtures/attribute-behavior/src/attributes.js b/fixtures/attribute-behavior/src/attributes.js index 6222dcc9a099f..afd902d61d4c3 100644 --- a/fixtures/attribute-behavior/src/attributes.js +++ b/fixtures/attribute-behavior/src/attributes.js @@ -356,12 +356,7 @@ const attributes = [ }, {name: 'cols', tagName: 'textarea'}, {name: 'colSpan', containerTagName: 'tr', tagName: 'td'}, - { - name: 'content', - containerTagName: 'head', - tagName: 'meta', - extraProps: {name: 'description'}, - }, + {name: 'content', containerTagName: 'head', tagName: 'meta'}, {name: 'contentEditable'}, { name: 'contentScriptType',