Skip to content

Commit 0cd8d47

Browse files
authored
Do not toLowerCase lists of lowercase words (#13428)
* Do not toLowerCase lists of lowercase words * Add notes about downcasing to DOMProperty.js * Use consistent comment breakout * Make toLowerCase more obvious
1 parent b3a4cfe commit 0cd8d47

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

packages/react-dom/src/shared/DOMProperty.js

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,35 +320,55 @@ const properties = {};
320320
'multiple',
321321
'muted',
322322
'selected',
323+
324+
// NOTE: if you add a camelCased prop to this list,
325+
// you'll need to set attributeName to name.toLowerCase()
326+
// instead in the assignment below.
323327
].forEach(name => {
324328
properties[name] = new PropertyInfoRecord(
325329
name,
326330
BOOLEAN,
327331
true, // mustUseProperty
328-
name.toLowerCase(), // attributeName
332+
name, // attributeName
329333
null, // attributeNamespace
330334
);
331335
});
332336

333337
// These are HTML attributes that are "overloaded booleans": they behave like
334338
// booleans, but can also accept a string value.
335-
['capture', 'download'].forEach(name => {
339+
[
340+
'capture',
341+
'download',
342+
343+
// NOTE: if you add a camelCased prop to this list,
344+
// you'll need to set attributeName to name.toLowerCase()
345+
// instead in the assignment below.
346+
].forEach(name => {
336347
properties[name] = new PropertyInfoRecord(
337348
name,
338349
OVERLOADED_BOOLEAN,
339350
false, // mustUseProperty
340-
name.toLowerCase(), // attributeName
351+
name, // attributeName
341352
null, // attributeNamespace
342353
);
343354
});
344355

345356
// These are HTML attributes that must be positive numbers.
346-
['cols', 'rows', 'size', 'span'].forEach(name => {
357+
[
358+
'cols',
359+
'rows',
360+
'size',
361+
'span',
362+
363+
// NOTE: if you add a camelCased prop to this list,
364+
// you'll need to set attributeName to name.toLowerCase()
365+
// instead in the assignment below.
366+
].forEach(name => {
347367
properties[name] = new PropertyInfoRecord(
348368
name,
349369
POSITIVE_NUMERIC,
350370
false, // mustUseProperty
351-
name.toLowerCase(), // attributeName
371+
name, // attributeName
352372
null, // attributeNamespace
353373
);
354374
});
@@ -446,6 +466,10 @@ const capitalize = token => token[1].toUpperCase();
446466
'writing-mode',
447467
'xmlns:xlink',
448468
'x-height',
469+
470+
// NOTE: if you add a camelCased prop to this list,
471+
// you'll need to set attributeName to name.toLowerCase()
472+
// instead in the assignment below.
449473
].forEach(attributeName => {
450474
const name = attributeName.replace(CAMELIZE, capitalize);
451475
properties[name] = new PropertyInfoRecord(
@@ -466,6 +490,10 @@ const capitalize = token => token[1].toUpperCase();
466490
'xlink:show',
467491
'xlink:title',
468492
'xlink:type',
493+
494+
// NOTE: if you add a camelCased prop to this list,
495+
// you'll need to set attributeName to name.toLowerCase()
496+
// instead in the assignment below.
469497
].forEach(attributeName => {
470498
const name = attributeName.replace(CAMELIZE, capitalize);
471499
properties[name] = new PropertyInfoRecord(
@@ -478,7 +506,15 @@ const capitalize = token => token[1].toUpperCase();
478506
});
479507

480508
// String SVG attributes with the xml namespace.
481-
['xml:base', 'xml:lang', 'xml:space'].forEach(attributeName => {
509+
[
510+
'xml:base',
511+
'xml:lang',
512+
'xml:space',
513+
514+
// NOTE: if you add a camelCased prop to this list,
515+
// you'll need to set attributeName to name.toLowerCase()
516+
// instead in the assignment below.
517+
].forEach(attributeName => {
482518
const name = attributeName.replace(CAMELIZE, capitalize);
483519
properties[name] = new PropertyInfoRecord(
484520
name,

0 commit comments

Comments
 (0)