Browse Source

Add simple string escape function

pull/3670/head
Artur Arseniev 5 years ago
parent
commit
900b6a0c40
  1. 10
      src/utils/mixins.js

10
src/utils/mixins.js

@ -167,6 +167,16 @@ export const find = (arr, test) => {
return result; return result;
}; };
export const escape = (str = '') => {
return `${str}`
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
.replace(/`/g, '&#96;');
};
/** /**
* Ensure to fetch the model from the input argument * Ensure to fetch the model from the input argument
* @param {HTMLElement|Component} el Component or HTML element * @param {HTMLElement|Component} el Component or HTML element

Loading…
Cancel
Save