Skip to content

Commit

Permalink
Compare char codes rather symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
dfilatov committed Aug 20, 2017
1 parent c219a8f commit a04f9cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/utils/escapeAttr.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default function escapeAttr(str) {
escapes = 0; // 1 — escape '&', 2 — escape '"'

while(i-- > 0) {
switch(str[i]) {
case '&':
switch(str.charCodeAt(i)) {
case 38:
escapes |= 1;
break;

case '"':
case 34:
escapes |= 2;
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/escapeHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ export default function escapeHtml(str) {
escapes = 0; // 1 — escape '&', 2 — escape '<', 4 — escape '>'

while(i-- > 0) {
switch(str[i]) {
case '&':
switch(str.charCodeAt(i)) {
case 38:
escapes |= 1;
break;

case '<':
case 60:
escapes |= 2;
break;

case '>':
case 62:
escapes |= 4;
break;
}
Expand Down

0 comments on commit a04f9cb

Please sign in to comment.