We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe749fb commit d82475fCopy full SHA for d82475f
src/util.js
@@ -1,11 +1,21 @@
1
// DOM properties that should NOT have "px" added when numeric
2
export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;
3
4
-export let encodeEntities = s => String(s)
5
- .replace(/&/g, '&')
6
- .replace(/</g, '<')
7
- .replace(/>/g, '>')
8
- .replace(/"/g, '"');
+export function encodeEntities(s) {
+ let out = '';
+ for (let i=0; i<s.length; i++) {
+ let ch = s[i];
+ switch (ch) {
9
+ case '<': ch = '<';
10
+ case '>': ch = '>';
11
+ case '"': ch = '"';
12
+ case '&': ch = '&';
13
+ }
14
+ out += ch;
15
16
+ return out;
17
+}
18
+
19
20
export let indent = (s, char) => String(s).replace(/(\n+)/g, '$1' + (char || '\t'));
21
0 commit comments