mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Remove dead HAS_SIDE_EFFECTS logic (#6987)
(cherry picked from commit 416b5ef173)
This commit is contained in:
1 parent
ec029f66cc
commit
8ea1ee14d5
2 files changed
+4
-27
No files matched your search
@@ -23,7 +23,6 @@ var DOMPropertyInjection = {
|
||||
* specifies how the associated DOM property should be accessed or rendered.
|
||||
*/
|
||||
MUST_USE_PROPERTY: 0x1,
|
||||
HAS_SIDE_EFFECTS: 0x2,
|
||||
HAS_BOOLEAN_VALUE: 0x4,
|
||||
HAS_NUMERIC_VALUE: 0x8,
|
||||
HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8,
|
||||
@@ -91,7 +90,6 @@ var DOMPropertyInjection = {
|
||||
mutationMethod: null,
|
||||
|
||||
mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
|
||||
hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS),
|
||||
hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
|
||||
hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
|
||||
hasPositiveNumericValue:
|
||||
@@ -99,12 +97,6 @@ var DOMPropertyInjection = {
|
||||
hasOverloadedBooleanValue:
|
||||
checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE),
|
||||
};
|
||||
|
||||
invariant(
|
||||
propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects,
|
||||
'DOMProperty: Properties that have side effects must use property: %s',
|
||||
propName
|
||||
);
|
||||
invariant(
|
||||
propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue +
|
||||
propertyInfo.hasOverloadedBooleanValue <= 1,
|
||||
@@ -183,11 +175,6 @@ var DOMProperty = {
|
||||
* initial render.
|
||||
* mustUseProperty:
|
||||
* Whether the property must be accessed and mutated as an object property.
|
||||
* hasSideEffects:
|
||||
* Whether or not setting a value causes side effects such as triggering
|
||||
* resources to be loaded or text selection changes. If true, we read from
|
||||
* the DOM before updating to ensure that the value is only set if it has
|
||||
* changed.
|
||||
* hasBooleanValue:
|
||||
* Whether the property should be removed when set to a falsey value.
|
||||
* hasNumericValue:
|
||||
|
||||
@@ -145,15 +145,9 @@ var DOMPropertyOperations = {
|
||||
this.deleteValueForProperty(node, name);
|
||||
return;
|
||||
} else if (propertyInfo.mustUseProperty) {
|
||||
var propName = propertyInfo.propertyName;
|
||||
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
||||
// property type before comparing; only `value` does and is string.
|
||||
if (!propertyInfo.hasSideEffects ||
|
||||
('' + node[propName]) !== ('' + value)) {
|
||||
// Contrary to `setAttribute`, object properties are properly
|
||||
// `toString`ed by IE8/9.
|
||||
node[propName] = value;
|
||||
}
|
||||
// Contrary to `setAttribute`, object properties are properly
|
||||
// `toString`ed by IE8/9.
|
||||
node[propertyInfo.propertyName] = value;
|
||||
} else {
|
||||
var attributeName = propertyInfo.attributeName;
|
||||
var namespace = propertyInfo.attributeNamespace;
|
||||
@@ -240,13 +234,9 @@ var DOMPropertyOperations = {
|
||||
} else if (propertyInfo.mustUseProperty) {
|
||||
var propName = propertyInfo.propertyName;
|
||||
if (propertyInfo.hasBooleanValue) {
|
||||
// No HAS_SIDE_EFFECTS logic here, only `value` has it and is string.
|
||||
node[propName] = false;
|
||||
} else {
|
||||
if (!propertyInfo.hasSideEffects ||
|
||||
('' + node[propName]) !== '') {
|
||||
node[propName] = '';
|
||||
}
|
||||
node[propName] = '';
|
||||
}
|
||||
} else {
|
||||
node.removeAttribute(propertyInfo.attributeName);
|
||||
|
||||
Reference in new issue
Block a user