Fixed #2363 - Tooltip | Escape encode enhancement

pull/2364/head
Tuğçe Küçükoğlu 2022-03-28 12:16:56 +03:00
parent 0124a70bfd
commit a3226ba4b0
2 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import {UniqueComponentId,DomHandler,ConnectedOverlayScrollHandler,ZIndexUtils} from 'primevue/utils'; import {UniqueComponentId,DomHandler,ConnectedOverlayScrollHandler,ZIndexUtils,ObjectUtils} from 'primevue/utils';
function bindEvents(el) { function bindEvents(el) {
const modifiers = el.$_ptooltipModifiers; const modifiers = el.$_ptooltipModifiers;
@ -105,7 +105,9 @@ function create(el) {
let tooltipText = document.createElement('div'); let tooltipText = document.createElement('div');
tooltipText.className = 'p-tooltip-text'; tooltipText.className = 'p-tooltip-text';
tooltipText.innerHTML = el.$_ptooltipValue;
let tooltipLabel = ObjectUtils.htmlEncode(el.$_ptooltipValue);
tooltipText.innerHTML = tooltipLabel;
container.appendChild(tooltipText); container.appendChild(tooltipText);
document.body.appendChild(container); document.body.appendChild(container);

View File

@ -204,6 +204,16 @@ export default {
return null; return null;
}, },
htmlEncode(str){
if (str) {
return str.replace(/[^\w. ]/gi, function(c){
return '&#'+c.charCodeAt(0)+';';
});
}
return null;
},
isEmpty(value) { isEmpty(value) {
return ( return (
value === null || value === undefined || value === '' || value === null || value === undefined || value === '' ||