Skip to content

Commit

Permalink
Fix logic around attribute seralization (#26526)
Browse files Browse the repository at this point in the history
This reverts commit ea499ef.

DiffTrain build for [66dc44e](66dc44e)
  • Loading branch information
kassens committed Apr 20, 2023
1 parent 91db3a0 commit 7d661b0
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 185 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a7b421fb4e0d0aa29aa2c3436c7c8756f2bae2d2
66dc44e7760d0f75b6845b7fa71f2f1e4e5f20d3
92 changes: 57 additions & 35 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-classic-81d2f28c";
var ReactVersion = "18.3.0-www-classic-83a1ba88";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -6311,52 +6311,63 @@ function writeStyleResourceAttributeInJS(destination, name, value) {
return;
// Attribute renames

case "className":
case "className": {
attributeName = "class";

{
checkAttributeStringCoercion(value, attributeName);
}

attributeValue = "" + value;
break;
}
// Booleans

case "hidden":
case "hidden": {
if (value === false) {
return;
}

attributeValue = "";
break;
}
// Santized URLs

case "src":
case "href": {
value = sanitizeURL(value);

{
checkAttributeStringCoercion(value, attributeName);
}

value = sanitizeURL(value);
attributeValue = "" + value;
break;
}

default: {
if (
// unrecognized event handlers are not SSR'd and we (apparently)
// use on* as hueristic for these handler props
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}

if (!isAttributeNameSafe(name)) {
return;
}
}
}

if (
// shouldIgnoreAttribute
// We have already filtered out null/undefined and reserved words.
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}
{
checkAttributeStringCoercion(value, attributeName);
}

{
checkAttributeStringCoercion(value, attributeName);
attributeValue = "" + value;
}
}

attributeValue = "" + value;
writeChunk(destination, arrayInterstitial);
writeChunk(
destination,
Expand Down Expand Up @@ -6502,52 +6513,63 @@ function writeStyleResourceAttributeInAttr(destination, name, value) {
return;
// Attribute renames

case "className":
case "className": {
attributeName = "class";

{
checkAttributeStringCoercion(value, attributeName);
}

attributeValue = "" + value;
break;
}
// Booleans

case "hidden":
case "hidden": {
if (value === false) {
return;
}

attributeValue = "";
break;
}
// Santized URLs

case "src":
case "href": {
value = sanitizeURL(value);

{
checkAttributeStringCoercion(value, attributeName);
}

value = sanitizeURL(value);
attributeValue = "" + value;
break;
}

default: {
if (
// unrecognized event handlers are not SSR'd and we (apparently)
// use on* as hueristic for these handler props
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}

if (!isAttributeNameSafe(name)) {
return;
}
}
}

if (
// shouldIgnoreAttribute
// We have already filtered out null/undefined and reserved words.
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}
{
checkAttributeStringCoercion(value, attributeName);
}

{
checkAttributeStringCoercion(value, attributeName);
attributeValue = "" + value;
}
}

attributeValue = "" + value;
writeChunk(destination, arrayInterstitial);
writeChunk(
destination,
Expand Down
92 changes: 57 additions & 35 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-modern-4e6bdd84";
var ReactVersion = "18.3.0-www-modern-06decfab";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -6311,52 +6311,63 @@ function writeStyleResourceAttributeInJS(destination, name, value) {
return;
// Attribute renames

case "className":
case "className": {
attributeName = "class";

{
checkAttributeStringCoercion(value, attributeName);
}

attributeValue = "" + value;
break;
}
// Booleans

case "hidden":
case "hidden": {
if (value === false) {
return;
}

attributeValue = "";
break;
}
// Santized URLs

case "src":
case "href": {
value = sanitizeURL(value);

{
checkAttributeStringCoercion(value, attributeName);
}

value = sanitizeURL(value);
attributeValue = "" + value;
break;
}

default: {
if (
// unrecognized event handlers are not SSR'd and we (apparently)
// use on* as hueristic for these handler props
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}

if (!isAttributeNameSafe(name)) {
return;
}
}
}

if (
// shouldIgnoreAttribute
// We have already filtered out null/undefined and reserved words.
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}
{
checkAttributeStringCoercion(value, attributeName);
}

{
checkAttributeStringCoercion(value, attributeName);
attributeValue = "" + value;
}
}

attributeValue = "" + value;
writeChunk(destination, arrayInterstitial);
writeChunk(
destination,
Expand Down Expand Up @@ -6502,52 +6513,63 @@ function writeStyleResourceAttributeInAttr(destination, name, value) {
return;
// Attribute renames

case "className":
case "className": {
attributeName = "class";

{
checkAttributeStringCoercion(value, attributeName);
}

attributeValue = "" + value;
break;
}
// Booleans

case "hidden":
case "hidden": {
if (value === false) {
return;
}

attributeValue = "";
break;
}
// Santized URLs

case "src":
case "href": {
value = sanitizeURL(value);

{
checkAttributeStringCoercion(value, attributeName);
}

value = sanitizeURL(value);
attributeValue = "" + value;
break;
}

default: {
if (
// unrecognized event handlers are not SSR'd and we (apparently)
// use on* as hueristic for these handler props
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}

if (!isAttributeNameSafe(name)) {
return;
}
}
}

if (
// shouldIgnoreAttribute
// We have already filtered out null/undefined and reserved words.
name.length > 2 &&
(name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")
) {
return;
}
{
checkAttributeStringCoercion(value, attributeName);
}

{
checkAttributeStringCoercion(value, attributeName);
attributeValue = "" + value;
}
}

attributeValue = "" + value;
writeChunk(destination, arrayInterstitial);
writeChunk(
destination,
Expand Down
Loading

0 comments on commit 7d661b0

Please sign in to comment.