mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-13 15:27:16 +03:00
Add HTML character escaping to src.dom.js
This commit is contained in:
parent
e25ccd960e
commit
062abeb86a
@ -1,4 +1,15 @@
|
||||
var DOM = (function(){
|
||||
var entityMap = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
"/": '/'
|
||||
};
|
||||
|
||||
var entityRegex = /[&<>"'\/]/g;
|
||||
|
||||
return {
|
||||
/*
|
||||
* Returns a child element by its ID. Parent defaults to the entire document.
|
||||
@ -35,6 +46,13 @@ var DOM = (function(){
|
||||
*/
|
||||
removeElement: function(ele){
|
||||
ele.parentNode.removeChild(ele);
|
||||
},
|
||||
|
||||
/*
|
||||
* Converts characters to their HTML entity form.
|
||||
*/
|
||||
escapeHTML: function(html){
|
||||
return html.replace(entityRegex, s => entityMap[s]);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
Loading…
x
Reference in New Issue
Block a user