Don't double-escape style names

Previously we were escaping both in createMarkupForStyles and then in createMarkupForProperty; now we escape only in the latter (otherwise the hypothetical style name `b&ckground` would become `b&ckground`).

Test Plan: grunt fasttest
This commit is contained in:
Ben Alpert
2014-04-29 15:50:12 -03:00
parent b9e215d169
commit da34209148
2 changed files with 8 additions and 2 deletions
@@ -252,6 +252,12 @@ describe('ReactDOMComponent', function() {
expect(genMarkup({ className: 'a b' })).toHaveAttribute('class', 'a b');
expect(genMarkup({ className: '' })).toHaveAttribute('class', '');
});
it("should escape style names and values", function() {
expect(genMarkup({
style: {'b&ckground': '<3'}
})).toHaveAttribute('style', 'b&amp;ckground:&lt;3;');
});
});
describe('createContentMarkup', function() {
+2 -2
View File
@@ -22,12 +22,11 @@
var CSSProperty = require('CSSProperty');
var dangerousStyleValue = require('dangerousStyleValue');
var escapeTextForBrowser = require('escapeTextForBrowser');
var hyphenateStyleName = require('hyphenateStyleName');
var memoizeStringOnly = require('memoizeStringOnly');
var processStyleName = memoizeStringOnly(function(styleName) {
return escapeTextForBrowser(hyphenateStyleName(styleName));
return hyphenateStyleName(styleName);
});
/**
@@ -42,6 +41,7 @@ var CSSPropertyOperations = {
* "width:200px;height:0;"
*
* Undefined values are ignored so that declarative programming is easier.
* The result should be HTML-escaped before insertion into the DOM.
*
* @param {object} styles
* @return {?string}