Merge pull request #2364 from tugcekucukoglu/tooltip

Fixed #2363 - Tooltip | Escape encode enhancement
pull/2368/head
Tuğçe Küçükoğlu 2022-03-28 12:17:32 +03:00 committed by GitHub
commit 6f48ac5eed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 === '' ||