Skip to content

Commit 2ca810f

Browse files
committed
Merge pull request #1225 from spicyj/cprop
Fix removing DOM property with mapped name
2 parents d9dd9d5 + 21e0619 commit 2ca810f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/browser/ui/dom/DOMPropertyOperations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ var DOMPropertyOperations = {
162162
var propName = DOMProperty.getPropertyName[name];
163163
var defaultValue = DOMProperty.getDefaultValueForProperty(
164164
node.nodeName,
165-
name
165+
propName
166166
);
167167
if (!DOMProperty.hasSideEffects[name] ||
168168
node[propName] !== defaultValue) {

src/browser/ui/dom/__tests__/DOMPropertyOperations-test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,33 @@ describe('DOMPropertyOperations', function() {
192192
expect(stubNode.className).toBe('');
193193
});
194194

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+
195222
});
196223

197224
describe('injectDOMPropertyConfig', function() {

0 commit comments

Comments
 (0)