fix escapeHtml
This commit is contained in:
parent
504a2e7135
commit
48d3a85037
|
@ -1,6 +1,7 @@
|
|||
<script>
|
||||
import Icon from './Icon';
|
||||
import spelling from "../plugins/spelling";
|
||||
import { escapeHtml } from '../src/helpers';
|
||||
|
||||
export default {
|
||||
mixins: [ spelling ],
|
||||
|
@ -12,7 +13,7 @@
|
|||
render(h) {
|
||||
let text = this.text;
|
||||
if (this.escape) {
|
||||
text = text.replace(/[&<>"]/g, tag => escapeChars[tag] || tag);
|
||||
text = escapeHtml(text);
|
||||
}
|
||||
if (!this.text) {
|
||||
return h('span');
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
<script>
|
||||
import spelling from "../plugins/spelling";
|
||||
|
||||
const escapeChars = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"'
|
||||
};
|
||||
import { escapeHtml } from '../src/helpers';
|
||||
|
||||
export default {
|
||||
mixins: [ spelling ],
|
||||
|
@ -18,7 +12,7 @@
|
|||
let text = this.text || '';
|
||||
text = text.replace('<script', '');
|
||||
if (this.escape) {
|
||||
text = text.replace(/[&<>"]/g, tag => escapeChars[tag] || tag);
|
||||
text = escapeHtml(text);
|
||||
}
|
||||
|
||||
return h('span', {domProps: { innerHTML: this.handleSpelling(text) }});
|
||||
|
|
|
@ -223,3 +223,12 @@ export const clearKey = (key) => {
|
|||
export const sleep = (milliseconds) => {
|
||||
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
||||
}
|
||||
|
||||
const escapeChars = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"'
|
||||
};
|
||||
|
||||
export const escapeHtml = (text) => text.replace(/[&<>"]/g, tag => escapeChars[tag] || tag);
|
||||
|
|
Reference in New Issue