Skip to content

Commit 5f66358

Browse files
committed
Restore old behavior for empty href props on anchor tags (#28124)
Treat `<a href="" />` the same with and without `enableFilterEmptyStringAttributesDOM` in #18513 we started to warn and ignore for empty `href` and `src` props since it usually hinted at a mistake. However, for anchor tags there's a valid use case since `<a href=""></a>` will by spec render a link to the current page. It could be used to reload the page without having to rely on browser affordances. The implementation for Fizz is in the spirit of #21153. I gated the fork behind the flag so that the fork is DCE'd when the flag is off. DiffTrain build for [f3ce87a](f3ce87a)
1 parent 3cc608a commit 5f66358

21 files changed

+1021
-712
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
417188314dd1d6df54efc8cd6a0c5d4830615888
1+
f3ce87ab650f07774e1df9bc3f8033e023973d10

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-www-classic-5e99f036";
27+
var ReactVersion = "18.3.0-www-classic-3dc9e724";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-www-modern-d235b405";
27+
var ReactVersion = "18.3.0-www-modern-4671cea1";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

69-
var ReactVersion = "18.3.0-www-modern-4fcabd82";
69+
var ReactVersion = "18.3.0-www-modern-c768d9b6";
7070

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35754,7 +35754,7 @@ if (__DEV__) {
3575435754
return root;
3575535755
}
3575635756

35757-
var ReactVersion = "18.3.0-www-classic-c52d28d4";
35757+
var ReactVersion = "18.3.0-www-classic-3799de5b";
3575835758

3575935759
function createPortal$1(
3576035760
children,
@@ -40608,7 +40608,10 @@ if (__DEV__) {
4060840608
case "src":
4060940609
case "href": {
4061040610
{
40611-
if (value === "") {
40611+
if (
40612+
value === "" && // <a href=""> is fine for "reload" links.
40613+
!(tag === "a" && key === "href")
40614+
) {
4061240615
{
4061340616
if (key === "src") {
4061440617
error(
@@ -42832,7 +42835,10 @@ if (__DEV__) {
4283242835
case "src":
4283342836
case "href":
4283442837
{
42835-
if (value === "") {
42838+
if (
42839+
value === "" && // <a href=""> is fine for "reload" links.
42840+
!(tag === "a" && propKey === "href")
42841+
) {
4283642842
{
4283742843
if (propKey === "src") {
4283842844
error(

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35575,7 +35575,7 @@ if (__DEV__) {
3557535575
return root;
3557635576
}
3557735577

35578-
var ReactVersion = "18.3.0-www-modern-8e7b2378";
35578+
var ReactVersion = "18.3.0-www-modern-41422569";
3557935579

3558035580
function createPortal$1(
3558135581
children,
@@ -41237,7 +41237,10 @@ if (__DEV__) {
4123741237
case "src":
4123841238
case "href": {
4123941239
{
41240-
if (value === "") {
41240+
if (
41241+
value === "" && // <a href=""> is fine for "reload" links.
41242+
!(tag === "a" && key === "href")
41243+
) {
4124141244
{
4124241245
if (key === "src") {
4124341246
error(
@@ -43458,7 +43461,10 @@ if (__DEV__) {
4345843461
case "src":
4345943462
case "href":
4346043463
{
43461-
if (value === "") {
43464+
if (
43465+
value === "" && // <a href=""> is fine for "reload" links.
43466+
!(tag === "a" && propKey === "href")
43467+
) {
4346243468
{
4346343469
if (propKey === "src") {
4346443470
error(

compiled/facebook-www/ReactDOM-prod.classic.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14331,7 +14331,7 @@ function setProp(domElement, tag, key, value, props, prevValue) {
1433114331
break;
1433214332
case "src":
1433314333
case "href":
14334-
if ("" === value) {
14334+
if ("" === value && ("a" !== tag || "href" !== key)) {
1433514335
domElement.removeAttribute(key);
1433614336
break;
1433714337
}
@@ -17154,7 +17154,7 @@ Internals.Events = [
1715417154
var devToolsConfig$jscomp$inline_1823 = {
1715517155
findFiberByHostInstance: getClosestInstanceFromNode,
1715617156
bundleType: 0,
17157-
version: "18.3.0-www-classic-3deaa9d4",
17157+
version: "18.3.0-www-classic-8280394c",
1715817158
rendererPackageName: "react-dom"
1715917159
};
1716017160
var internals$jscomp$inline_2185 = {
@@ -17184,7 +17184,7 @@ var internals$jscomp$inline_2185 = {
1718417184
scheduleRoot: null,
1718517185
setRefreshHandler: null,
1718617186
getCurrentFiber: null,
17187-
reconcilerVersion: "18.3.0-www-classic-3deaa9d4"
17187+
reconcilerVersion: "18.3.0-www-classic-8280394c"
1718817188
};
1718917189
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1719017190
var hook$jscomp$inline_2186 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17534,4 +17534,4 @@ exports.useFormStatus = function () {
1753417534
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
1753517535
throw Error(formatProdErrorMessage(248));
1753617536
};
17537-
exports.version = "18.3.0-www-classic-3deaa9d4";
17537+
exports.version = "18.3.0-www-classic-8280394c";

compiled/facebook-www/ReactDOM-prod.modern.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14633,7 +14633,7 @@ function setProp(domElement, tag, key, value, props, prevValue) {
1463314633
break;
1463414634
case "src":
1463514635
case "href":
14636-
if ("" === value) {
14636+
if ("" === value && ("a" !== tag || "href" !== key)) {
1463714637
domElement.removeAttribute(key);
1463814638
break;
1463914639
}
@@ -16677,7 +16677,7 @@ Internals.Events = [
1667716677
var devToolsConfig$jscomp$inline_1782 = {
1667816678
findFiberByHostInstance: getClosestInstanceFromNode,
1667916679
bundleType: 0,
16680-
version: "18.3.0-www-modern-2bb5f73b",
16680+
version: "18.3.0-www-modern-3c4feb2e",
1668116681
rendererPackageName: "react-dom"
1668216682
};
1668316683
var internals$jscomp$inline_2149 = {
@@ -16708,7 +16708,7 @@ var internals$jscomp$inline_2149 = {
1670816708
scheduleRoot: null,
1670916709
setRefreshHandler: null,
1671016710
getCurrentFiber: null,
16711-
reconcilerVersion: "18.3.0-www-modern-2bb5f73b"
16711+
reconcilerVersion: "18.3.0-www-modern-3c4feb2e"
1671216712
};
1671316713
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1671416714
var hook$jscomp$inline_2150 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16986,4 +16986,4 @@ exports.useFormStatus = function () {
1698616986
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
1698716987
throw Error(formatProdErrorMessage(248));
1698816988
};
16989-
exports.version = "18.3.0-www-modern-2bb5f73b";
16989+
exports.version = "18.3.0-www-modern-3c4feb2e";

compiled/facebook-www/ReactDOM-profiling.classic.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15100,7 +15100,7 @@ function setProp(domElement, tag, key, value, props, prevValue) {
1510015100
break;
1510115101
case "src":
1510215102
case "href":
15103-
if ("" === value) {
15103+
if ("" === value && ("a" !== tag || "href" !== key)) {
1510415104
domElement.removeAttribute(key);
1510515105
break;
1510615106
}
@@ -17923,7 +17923,7 @@ Internals.Events = [
1792317923
var devToolsConfig$jscomp$inline_1908 = {
1792417924
findFiberByHostInstance: getClosestInstanceFromNode,
1792517925
bundleType: 0,
17926-
version: "18.3.0-www-classic-3ac173cd",
17926+
version: "18.3.0-www-classic-ec24bb93",
1792717927
rendererPackageName: "react-dom"
1792817928
};
1792917929
(function (internals) {
@@ -17967,7 +17967,7 @@ var devToolsConfig$jscomp$inline_1908 = {
1796717967
scheduleRoot: null,
1796817968
setRefreshHandler: null,
1796917969
getCurrentFiber: null,
17970-
reconcilerVersion: "18.3.0-www-classic-3ac173cd"
17970+
reconcilerVersion: "18.3.0-www-classic-ec24bb93"
1797117971
});
1797217972
assign(Internals, {
1797317973
ReactBrowserEventEmitter: {
@@ -18304,7 +18304,7 @@ exports.useFormStatus = function () {
1830418304
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
1830518305
throw Error(formatProdErrorMessage(248));
1830618306
};
18307-
exports.version = "18.3.0-www-classic-3ac173cd";
18307+
exports.version = "18.3.0-www-classic-ec24bb93";
1830818308
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1830918309
"function" ===
1831018310
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactDOM-profiling.modern.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15396,7 +15396,7 @@ function setProp(domElement, tag, key, value, props, prevValue) {
1539615396
break;
1539715397
case "src":
1539815398
case "href":
15399-
if ("" === value) {
15399+
if ("" === value && ("a" !== tag || "href" !== key)) {
1540015400
domElement.removeAttribute(key);
1540115401
break;
1540215402
}
@@ -17440,7 +17440,7 @@ Internals.Events = [
1744017440
var devToolsConfig$jscomp$inline_1867 = {
1744117441
findFiberByHostInstance: getClosestInstanceFromNode,
1744217442
bundleType: 0,
17443-
version: "18.3.0-www-modern-4fcabd82",
17443+
version: "18.3.0-www-modern-c768d9b6",
1744417444
rendererPackageName: "react-dom"
1744517445
};
1744617446
(function (internals) {
@@ -17485,7 +17485,7 @@ var devToolsConfig$jscomp$inline_1867 = {
1748517485
scheduleRoot: null,
1748617486
setRefreshHandler: null,
1748717487
getCurrentFiber: null,
17488-
reconcilerVersion: "18.3.0-www-modern-4fcabd82"
17488+
reconcilerVersion: "18.3.0-www-modern-c768d9b6"
1748917489
});
1749017490
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
1749117491
exports.createPortal = function (children, container) {
@@ -17750,7 +17750,7 @@ exports.useFormStatus = function () {
1775017750
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
1775117751
throw Error(formatProdErrorMessage(248));
1775217752
};
17753-
exports.version = "18.3.0-www-modern-4fcabd82";
17753+
exports.version = "18.3.0-www-modern-c768d9b6";
1775417754
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1775517755
"function" ===
1775617756
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)