Skip to content

Commit 7d661b0

Browse files
committed
Fix logic around attribute seralization (#26526)
This reverts commit ea499ef. DiffTrain build for [66dc44e](66dc44e)
1 parent 91db3a0 commit 7d661b0

7 files changed

+275
-185
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a7b421fb4e0d0aa29aa2c3436c7c8756f2bae2d2
1+
66dc44e7760d0f75b6845b7fa71f2f1e4e5f20d3

compiled/facebook-www/ReactDOMServer-dev.classic.js

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

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

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

6314-
case "className":
6314+
case "className": {
63156315
attributeName = "class";
6316+
6317+
{
6318+
checkAttributeStringCoercion(value, attributeName);
6319+
}
6320+
6321+
attributeValue = "" + value;
63166322
break;
6323+
}
63176324
// Booleans
63186325

6319-
case "hidden":
6326+
case "hidden": {
63206327
if (value === false) {
63216328
return;
63226329
}
63236330

63246331
attributeValue = "";
63256332
break;
6333+
}
63266334
// Santized URLs
63276335

63286336
case "src":
63296337
case "href": {
6338+
value = sanitizeURL(value);
6339+
63306340
{
63316341
checkAttributeStringCoercion(value, attributeName);
63326342
}
63336343

6334-
value = sanitizeURL(value);
6344+
attributeValue = "" + value;
63356345
break;
63366346
}
63376347

63386348
default: {
6349+
if (
6350+
// unrecognized event handlers are not SSR'd and we (apparently)
6351+
// use on* as hueristic for these handler props
6352+
name.length > 2 &&
6353+
(name[0] === "o" || name[0] === "O") &&
6354+
(name[1] === "n" || name[1] === "N")
6355+
) {
6356+
return;
6357+
}
6358+
63396359
if (!isAttributeNameSafe(name)) {
63406360
return;
63416361
}
6342-
}
6343-
}
63446362

6345-
if (
6346-
// shouldIgnoreAttribute
6347-
// We have already filtered out null/undefined and reserved words.
6348-
name.length > 2 &&
6349-
(name[0] === "o" || name[0] === "O") &&
6350-
(name[1] === "n" || name[1] === "N")
6351-
) {
6352-
return;
6353-
}
6363+
{
6364+
checkAttributeStringCoercion(value, attributeName);
6365+
}
63546366

6355-
{
6356-
checkAttributeStringCoercion(value, attributeName);
6367+
attributeValue = "" + value;
6368+
}
63576369
}
63586370

6359-
attributeValue = "" + value;
63606371
writeChunk(destination, arrayInterstitial);
63616372
writeChunk(
63626373
destination,
@@ -6502,52 +6513,63 @@ function writeStyleResourceAttributeInAttr(destination, name, value) {
65026513
return;
65036514
// Attribute renames
65046515

6505-
case "className":
6516+
case "className": {
65066517
attributeName = "class";
6518+
6519+
{
6520+
checkAttributeStringCoercion(value, attributeName);
6521+
}
6522+
6523+
attributeValue = "" + value;
65076524
break;
6525+
}
65086526
// Booleans
65096527

6510-
case "hidden":
6528+
case "hidden": {
65116529
if (value === false) {
65126530
return;
65136531
}
65146532

65156533
attributeValue = "";
65166534
break;
6535+
}
65176536
// Santized URLs
65186537

65196538
case "src":
65206539
case "href": {
6540+
value = sanitizeURL(value);
6541+
65216542
{
65226543
checkAttributeStringCoercion(value, attributeName);
65236544
}
65246545

6525-
value = sanitizeURL(value);
6546+
attributeValue = "" + value;
65266547
break;
65276548
}
65286549

65296550
default: {
6551+
if (
6552+
// unrecognized event handlers are not SSR'd and we (apparently)
6553+
// use on* as hueristic for these handler props
6554+
name.length > 2 &&
6555+
(name[0] === "o" || name[0] === "O") &&
6556+
(name[1] === "n" || name[1] === "N")
6557+
) {
6558+
return;
6559+
}
6560+
65306561
if (!isAttributeNameSafe(name)) {
65316562
return;
65326563
}
6533-
}
6534-
}
65356564

6536-
if (
6537-
// shouldIgnoreAttribute
6538-
// We have already filtered out null/undefined and reserved words.
6539-
name.length > 2 &&
6540-
(name[0] === "o" || name[0] === "O") &&
6541-
(name[1] === "n" || name[1] === "N")
6542-
) {
6543-
return;
6544-
}
6565+
{
6566+
checkAttributeStringCoercion(value, attributeName);
6567+
}
65456568

6546-
{
6547-
checkAttributeStringCoercion(value, attributeName);
6569+
attributeValue = "" + value;
6570+
}
65486571
}
65496572

6550-
attributeValue = "" + value;
65516573
writeChunk(destination, arrayInterstitial);
65526574
writeChunk(
65536575
destination,

compiled/facebook-www/ReactDOMServer-dev.modern.js

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

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

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

6314-
case "className":
6314+
case "className": {
63156315
attributeName = "class";
6316+
6317+
{
6318+
checkAttributeStringCoercion(value, attributeName);
6319+
}
6320+
6321+
attributeValue = "" + value;
63166322
break;
6323+
}
63176324
// Booleans
63186325

6319-
case "hidden":
6326+
case "hidden": {
63206327
if (value === false) {
63216328
return;
63226329
}
63236330

63246331
attributeValue = "";
63256332
break;
6333+
}
63266334
// Santized URLs
63276335

63286336
case "src":
63296337
case "href": {
6338+
value = sanitizeURL(value);
6339+
63306340
{
63316341
checkAttributeStringCoercion(value, attributeName);
63326342
}
63336343

6334-
value = sanitizeURL(value);
6344+
attributeValue = "" + value;
63356345
break;
63366346
}
63376347

63386348
default: {
6349+
if (
6350+
// unrecognized event handlers are not SSR'd and we (apparently)
6351+
// use on* as hueristic for these handler props
6352+
name.length > 2 &&
6353+
(name[0] === "o" || name[0] === "O") &&
6354+
(name[1] === "n" || name[1] === "N")
6355+
) {
6356+
return;
6357+
}
6358+
63396359
if (!isAttributeNameSafe(name)) {
63406360
return;
63416361
}
6342-
}
6343-
}
63446362

6345-
if (
6346-
// shouldIgnoreAttribute
6347-
// We have already filtered out null/undefined and reserved words.
6348-
name.length > 2 &&
6349-
(name[0] === "o" || name[0] === "O") &&
6350-
(name[1] === "n" || name[1] === "N")
6351-
) {
6352-
return;
6353-
}
6363+
{
6364+
checkAttributeStringCoercion(value, attributeName);
6365+
}
63546366

6355-
{
6356-
checkAttributeStringCoercion(value, attributeName);
6367+
attributeValue = "" + value;
6368+
}
63576369
}
63586370

6359-
attributeValue = "" + value;
63606371
writeChunk(destination, arrayInterstitial);
63616372
writeChunk(
63626373
destination,
@@ -6502,52 +6513,63 @@ function writeStyleResourceAttributeInAttr(destination, name, value) {
65026513
return;
65036514
// Attribute renames
65046515

6505-
case "className":
6516+
case "className": {
65066517
attributeName = "class";
6518+
6519+
{
6520+
checkAttributeStringCoercion(value, attributeName);
6521+
}
6522+
6523+
attributeValue = "" + value;
65076524
break;
6525+
}
65086526
// Booleans
65096527

6510-
case "hidden":
6528+
case "hidden": {
65116529
if (value === false) {
65126530
return;
65136531
}
65146532

65156533
attributeValue = "";
65166534
break;
6535+
}
65176536
// Santized URLs
65186537

65196538
case "src":
65206539
case "href": {
6540+
value = sanitizeURL(value);
6541+
65216542
{
65226543
checkAttributeStringCoercion(value, attributeName);
65236544
}
65246545

6525-
value = sanitizeURL(value);
6546+
attributeValue = "" + value;
65266547
break;
65276548
}
65286549

65296550
default: {
6551+
if (
6552+
// unrecognized event handlers are not SSR'd and we (apparently)
6553+
// use on* as hueristic for these handler props
6554+
name.length > 2 &&
6555+
(name[0] === "o" || name[0] === "O") &&
6556+
(name[1] === "n" || name[1] === "N")
6557+
) {
6558+
return;
6559+
}
6560+
65306561
if (!isAttributeNameSafe(name)) {
65316562
return;
65326563
}
6533-
}
6534-
}
65356564

6536-
if (
6537-
// shouldIgnoreAttribute
6538-
// We have already filtered out null/undefined and reserved words.
6539-
name.length > 2 &&
6540-
(name[0] === "o" || name[0] === "O") &&
6541-
(name[1] === "n" || name[1] === "N")
6542-
) {
6543-
return;
6544-
}
6565+
{
6566+
checkAttributeStringCoercion(value, attributeName);
6567+
}
65456568

6546-
{
6547-
checkAttributeStringCoercion(value, attributeName);
6569+
attributeValue = "" + value;
6570+
}
65486571
}
65496572

6550-
attributeValue = "" + value;
65516573
writeChunk(destination, arrayInterstitial);
65526574
writeChunk(
65536575
destination,

0 commit comments

Comments
 (0)