Skip to content
This repository has been archived by the owner on Jul 9, 2018. It is now read-only.

Commit

Permalink
sanitizeText: reuse the textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Silverstein committed Aug 17, 2017
1 parent e504523 commit 4eb3d86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/sanitize/src/sanitizeText.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import stripTags from './stripTags';

// Create a reusable text area.
var textarea = document.createElement( 'textarea' );

/**
* Make a string safe for rendering.
*
Expand All @@ -10,8 +13,7 @@ import stripTags from './stripTags';
* @return Sanitized text. False on failure.
*/
export function sanitizeText( text ) {
var _text = wp.utils.stripTags( text ),
textarea = document.createElement( 'textarea' );
var _text = wp.utils.stripTags( text );

try {
textarea.innerHTML = _text;
Expand All @@ -20,3 +22,4 @@ export function sanitizeText( text ) {

return _text;
}

0 comments on commit 4eb3d86

Please sign in to comment.