Skip to content

Commit c64b73f

Browse files
committed
Remove DOM injection for HAS_NUMERIC_VALUE flag
1 parent a6b9dd5 commit c64b73f

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

src/renderers/dom/shared/DOMProperty.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ var DOMPropertyInjection = {
100100

101101
var propertyInfo = {
102102
hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
103-
hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
104103
hasOverloadedBooleanValue: checkMask(
105104
propConfig,
106105
Injection.HAS_OVERLOADED_BOOLEAN_VALUE,
@@ -111,9 +110,7 @@ var DOMPropertyInjection = {
111110
),
112111
};
113112
invariant(
114-
propertyInfo.hasBooleanValue +
115-
propertyInfo.hasNumericValue +
116-
propertyInfo.hasOverloadedBooleanValue <=
113+
propertyInfo.hasBooleanValue + propertyInfo.hasOverloadedBooleanValue <=
117114
1,
118115
'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
119116
'numeric value, but not a combination: %s',
@@ -286,9 +283,6 @@ var DOMProperty = {
286283
*
287284
* hasBooleanValue:
288285
* Whether the property should be removed when set to a falsey value.
289-
* hasNumericValue:
290-
* Whether the property must be numeric or parse as a numeric and should be
291-
* removed when set to a falsey value.
292286
* hasOverloadedBooleanValue:
293287
* Whether the property can be used as a flag as well as with a value.
294288
* Removed when strictly equal to false; present without a value when
@@ -368,30 +362,32 @@ var DOMProperty = {
368362
: null;
369363
},
370364

371-
// Whether the property must be positive numeric or parse as a positive
372-
// numeric and should be removed when set to a falsey value.
373-
isExpectingPositiveValue(propName) {
374-
switch (propName) {
365+
shouldIgnoreValue(name, value) {
366+
if (value == null) {
367+
return true;
368+
}
369+
switch (name) {
370+
// Numeric properties.
371+
case 'rowSpan':
372+
case 'start':
373+
return isNaN(value);
374+
// Positive numeric properties.
375375
case 'cols':
376376
case 'rows':
377377
case 'size':
378378
case 'span':
379-
return true;
379+
return isNaN(value) || value < 1;
380380
default:
381+
var propertyInfo = DOMProperty.getPropertyInfo(name);
382+
if (propertyInfo.hasBooleanValue && !value) {
383+
return true;
384+
}
385+
if (propertyInfo.hasOverloadedBooleanValue && value === false) {
386+
return true;
387+
}
381388
return false;
382389
}
383-
},
384-
385-
shouldIgnoreValue(name, value) {
386-
var propertyInfo = DOMProperty.getPropertyInfo(name);
387-
return (
388-
value == null ||
389-
(propertyInfo.hasBooleanValue && !value) ||
390-
(propertyInfo.hasNumericValue &&
391-
(isNaN(value) ||
392-
(DOMProperty.isExpectingPositiveValue(name) && value < 1))) ||
393-
(propertyInfo.hasOverloadedBooleanValue && value === false)
394-
);
390+
return false;
395391
},
396392

397393
shouldUseProperty(propName) {

src/renderers/dom/shared/HTMLDOMPropertyConfig.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
var DOMProperty = require('DOMProperty');
1515

1616
var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
17-
var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
1817
var HAS_OVERLOADED_BOOLEAN_VALUE =
1918
DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
2019
var HAS_STRING_BOOLEAN_VALUE = DOMProperty.injection.HAS_STRING_BOOLEAN_VALUE;
@@ -35,7 +34,7 @@ var HTMLDOMPropertyConfig = {
3534
autoPlay: HAS_BOOLEAN_VALUE,
3635
capture: HAS_BOOLEAN_VALUE,
3736
checked: HAS_BOOLEAN_VALUE,
38-
cols: HAS_NUMERIC_VALUE,
37+
cols: 0,
3938
contentEditable: HAS_STRING_BOOLEAN_VALUE,
4039
controls: HAS_BOOLEAN_VALUE,
4140
default: HAS_BOOLEAN_VALUE,
@@ -54,15 +53,15 @@ var HTMLDOMPropertyConfig = {
5453
readOnly: HAS_BOOLEAN_VALUE,
5554
required: HAS_BOOLEAN_VALUE,
5655
reversed: HAS_BOOLEAN_VALUE,
57-
rows: HAS_NUMERIC_VALUE,
58-
rowSpan: HAS_NUMERIC_VALUE,
56+
rows: 0,
57+
rowSpan: 0,
5958
scoped: HAS_BOOLEAN_VALUE,
6059
seamless: HAS_BOOLEAN_VALUE,
6160
selected: HAS_BOOLEAN_VALUE,
62-
size: HAS_NUMERIC_VALUE,
63-
start: HAS_NUMERIC_VALUE,
61+
size: 0,
62+
start: 0,
6463
// support for projecting regular DOM Elements via V1 named slots ( shadow dom )
65-
span: HAS_NUMERIC_VALUE,
64+
span: 0,
6665
spellCheck: HAS_STRING_BOOLEAN_VALUE,
6766
// Style must be explicitly set in the attribute list. React components
6867
// expect a style object

0 commit comments

Comments
 (0)