@samitouri / QOS-React / commits / 416b5ef173

Remove dead HAS_SIDE_EFFECTS logic (#6987)

Jim committed Jun 22, 2016 at 16:12 UTC 416b5ef17343acebfd19e1436e3b2990e99e1d0e
2 files changed +4 -27
src/renderers/dom/shared/DOMProperty.js
-13
@@ -23,7 +23,6 @@ var DOMPropertyInjection = {
23 * specifies how the associated DOM property should be accessed or rendered.
24 */
25 MUST_USE_PROPERTY: 0x1,
26 - HAS_SIDE_EFFECTS: 0x2,
26 HAS_BOOLEAN_VALUE: 0x4,
27 HAS_NUMERIC_VALUE: 0x8,
28 HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8,
@@ -91,7 +90,6 @@ var DOMPropertyInjection = {
90 mutationMethod: null,
91
92 mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
94 - hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS),
93 hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
94 hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
95 hasPositiveNumericValue:
@@ -99,12 +97,6 @@ var DOMPropertyInjection = {
97 hasOverloadedBooleanValue:
98 checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE),
99 };
102 -
103 - invariant(
104 - propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects,
105 - 'DOMProperty: Properties that have side effects must use property: %s',
106 - propName
107 - );
100 invariant(
101 propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue +
102 propertyInfo.hasOverloadedBooleanValue <= 1,
@@ -183,11 +175,6 @@ var DOMProperty = {
175 * initial render.
176 * mustUseProperty:
177 * Whether the property must be accessed and mutated as an object property.
186 - * hasSideEffects:
187 - * Whether or not setting a value causes side effects such as triggering
188 - * resources to be loaded or text selection changes. If true, we read from
189 - * the DOM before updating to ensure that the value is only set if it has
190 - * changed.
178 * hasBooleanValue:
179 * Whether the property should be removed when set to a falsey value.
180 * hasNumericValue:
src/renderers/dom/shared/DOMPropertyOperations.js
+4 -14
@@ -145,15 +145,9 @@ var DOMPropertyOperations = {
145 this.deleteValueForProperty(node, name);
146 return;
147 } else if (propertyInfo.mustUseProperty) {
148 - var propName = propertyInfo.propertyName;
149 - // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
150 - // property type before comparing; only `value` does and is string.
151 - if (!propertyInfo.hasSideEffects ||
152 - ('' + node[propName]) !== ('' + value)) {
153 - // Contrary to `setAttribute`, object properties are properly
154 - // `toString`ed by IE8/9.
155 - node[propName] = value;
156 - }
148 + // Contrary to `setAttribute`, object properties are properly
149 + // `toString`ed by IE8/9.
150 + node[propertyInfo.propertyName] = value;
151 } else {
152 var attributeName = propertyInfo.attributeName;
153 var namespace = propertyInfo.attributeNamespace;
@@ -240,13 +234,9 @@ var DOMPropertyOperations = {
234 } else if (propertyInfo.mustUseProperty) {
235 var propName = propertyInfo.propertyName;
236 if (propertyInfo.hasBooleanValue) {
243 - // No HAS_SIDE_EFFECTS logic here, only `value` has it and is string.
237 node[propName] = false;
238 } else {
246 - if (!propertyInfo.hasSideEffects ||
247 - ('' + node[propName]) !== '') {
248 - node[propName] = '';
249 - }
239 + node[propName] = '';
240 }
241 } else {
242 node.removeAttribute(propertyInfo.attributeName);