From 21e06196cd47e396b74119ad3e30fab9ead71482 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Thu, 6 Mar 2014 00:30:40 -0800 Subject: [PATCH] Fix removing DOM property with mapped name --- src/browser/ui/dom/DOMPropertyOperations.js | 2 +- .../__tests__/DOMPropertyOperations-test.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/browser/ui/dom/DOMPropertyOperations.js b/src/browser/ui/dom/DOMPropertyOperations.js index ae1e39d6329..29e9fbe255e 100644 --- a/src/browser/ui/dom/DOMPropertyOperations.js +++ b/src/browser/ui/dom/DOMPropertyOperations.js @@ -162,7 +162,7 @@ var DOMPropertyOperations = { var propName = DOMProperty.getPropertyName[name]; var defaultValue = DOMProperty.getDefaultValueForProperty( node.nodeName, - name + propName ); if (!DOMProperty.hasSideEffects[name] || node[propName] !== defaultValue) { diff --git a/src/browser/ui/dom/__tests__/DOMPropertyOperations-test.js b/src/browser/ui/dom/__tests__/DOMPropertyOperations-test.js index b074449e189..83e44161d4b 100644 --- a/src/browser/ui/dom/__tests__/DOMPropertyOperations-test.js +++ b/src/browser/ui/dom/__tests__/DOMPropertyOperations-test.js @@ -192,6 +192,33 @@ describe('DOMPropertyOperations', function() { expect(stubNode.className).toBe(''); }); + it('should remove property properly even with different name', function() { + // Suppose 'foobar' is a property that corresponds to the underlying + // 'className' property: + DOMProperty.injection.injectDOMPropertyConfig({ + Properties: {foobar: DOMProperty.injection.MUST_USE_PROPERTY}, + DOMPropertyNames: { + foobar: 'className' + } + }); + + DOMPropertyOperations.setValueForProperty( + stubNode, + 'foobar', + 'selected' + ); + expect(stubNode.className).toBe('selected'); + + DOMPropertyOperations.setValueForProperty( + stubNode, + 'foobar', + null + ); + // className should be '', not 'null' or null (which becomes 'null' in + // some browsers) + expect(stubNode.className).toBe(''); + }); + }); describe('injectDOMPropertyConfig', function() {