forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop .textContent IE8 polyfill and rewrite escaping tests against pub…
…lic API (facebook#11331) * Rename escapeText util. Test quoteAttributeValueForBrowser through ReactDOMServer API * Fix lint errors * Prettier reformatting * Change syntax to prevent prettier escape doble quote * Name and description gardening. Add tests for escapeTextForBrowser. Add missing tests * Improve script tag as text content test * Update escapeTextForBrowser-test.js * Update quoteAttributeValueForBrowser-test.js * Simplify tests * Move utilities to server folder
- Loading branch information
1 parent
f92cb85
commit e391819
Showing
9 changed files
with
129 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
packages/react-dom/src/__tests__/escapeTextContentForBrowser-test.js
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
packages/react-dom/src/__tests__/escapeTextForBrowser-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var React; | ||
var ReactDOMServer; | ||
|
||
describe('escapeTextForBrowser', () => { | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
React = require('react'); | ||
ReactDOMServer = require('react-dom/server'); | ||
}); | ||
|
||
it('ampersand is escaped when passed as text content', () => { | ||
var response = ReactDOMServer.renderToString(<span>{'&'}</span>); | ||
expect(response).toMatch('<span data-reactroot="">&</span>'); | ||
}); | ||
|
||
it('double quote is escaped when passed as text content', () => { | ||
var response = ReactDOMServer.renderToString(<span>{'"'}</span>); | ||
expect(response).toMatch('<span data-reactroot="">"</span>'); | ||
}); | ||
|
||
it('single quote is escaped when passed as text content', () => { | ||
var response = ReactDOMServer.renderToString(<span>{"'"}</span>); | ||
expect(response).toMatch('<span data-reactroot="">'</span>'); | ||
}); | ||
|
||
it('greater than entity is escaped when passed as text content', () => { | ||
var response = ReactDOMServer.renderToString(<span>{'>'}</span>); | ||
expect(response).toMatch('<span data-reactroot="">></span>'); | ||
}); | ||
|
||
it('lower than entity is escaped when passed as text content', () => { | ||
var response = ReactDOMServer.renderToString(<span>{'<'}</span>); | ||
expect(response).toMatch('<span data-reactroot=""><</span>'); | ||
}); | ||
|
||
it('number is correctly passed as text content', () => { | ||
var response = ReactDOMServer.renderToString(<span>{42}</span>); | ||
expect(response).toMatch('<span data-reactroot="">42</span>'); | ||
}); | ||
|
||
it('number is escaped to string when passed as text content', () => { | ||
var response = ReactDOMServer.renderToString(<img data-attr={42} />); | ||
expect(response).toMatch('<img data-attr="42" data-reactroot=""/>'); | ||
}); | ||
|
||
it('escape text content representing a script tag', () => { | ||
var response = ReactDOMServer.renderToString( | ||
<span>{'<script type=\'\' src=""></script>'}</span>, | ||
); | ||
expect(response).toMatch( | ||
'<span data-reactroot=""><script type='' ' + | ||
'src=""></script></span>', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters