Skip to content

Commit

Permalink
remove unnecessary unescape function (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
pveyes authored Jan 25, 2020
1 parent a827808 commit 1281bef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: node_js

node_js:
- "8"
- "10"
- "12"

cache:
yarn: true
Expand Down
11 changes: 1 addition & 10 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@ const NodeTypes = {

const TABLE_ELEMENTS = ['table', 'tbody', 'thead', 'tfoot', 'tr'];

const tempEl = document.createElement('div');
function unescape(str: string): string {
// Here we use innerHTML to unescape html entities.
// This is okay because we use the returned value as react children
// not dangerouslySetInnerHTML
tempEl.innerHTML = str;
return tempEl.textContent!;
}

function transform(node: any, key: string, options: HtmrOptions): ReactNode {
const defaultTransform = options.transform._;

if (node.nodeType === NodeTypes.COMMENT) {
return null;
} else if (node.nodeType === NodeTypes.TEXT) {
const text = unescape(node.textContent);
const text = node.textContent;
return defaultTransform ? defaultTransform(text) : text;
}

Expand Down

0 comments on commit 1281bef

Please sign in to comment.