@samitouri / QOS-React-2 / commits / 21e06196cd

Fix removing DOM property with mapped name

Ben Alpert committed Mar 6, 2014 at 00:30 UTC 21e06196cd47e396b74119ad3e30fab9ead71482
2 files changed +28 -1
src/browser/ui/dom/DOMPropertyOperations.js
+1 -1
@@ -162,7 +162,7 @@ var DOMPropertyOperations = {
162 var propName = DOMProperty.getPropertyName[name];
163 var defaultValue = DOMProperty.getDefaultValueForProperty(
164 node.nodeName,
165 - name
165 + propName
166 );
167 if (!DOMProperty.hasSideEffects[name] ||
168 node[propName] !== defaultValue) {
src/browser/ui/dom/__tests__/DOMPropertyOperations-test.js
+27
@@ -192,6 +192,33 @@ describe('DOMPropertyOperations', function() {
192 expect(stubNode.className).toBe('');
193 });
194
195 + it('should remove property properly even with different name', function() {
196 + // Suppose 'foobar' is a property that corresponds to the underlying
197 + // 'className' property:
198 + DOMProperty.injection.injectDOMPropertyConfig({
199 + Properties: {foobar: DOMProperty.injection.MUST_USE_PROPERTY},
200 + DOMPropertyNames: {
201 + foobar: 'className'
202 + }
203 + });
204 +
205 + DOMPropertyOperations.setValueForProperty(
206 + stubNode,
207 + 'foobar',
208 + 'selected'
209 + );
210 + expect(stubNode.className).toBe('selected');
211 +
212 + DOMPropertyOperations.setValueForProperty(
213 + stubNode,
214 + 'foobar',
215 + null
216 + );
217 + // className should be '', not 'null' or null (which becomes 'null' in
218 + // some browsers)
219 + expect(stubNode.className).toBe('');
220 + });
221 +
222 });
223
224 describe('injectDOMPropertyConfig', function() {