Skip to content

Commit

Permalink
Fixed #2363
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Mar 30, 2022
1 parent 890b670 commit 6424fe3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 13 additions & 3 deletions src/components/tooltip/Tooltip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UniqueComponentId,DomHandler,ConnectedOverlayScrollHandler,ZIndexUtils,ObjectUtils} from 'primevue/utils';
import {UniqueComponentId,DomHandler,ConnectedOverlayScrollHandler,ZIndexUtils} from 'primevue/utils';

function bindEvents(el) {
const modifiers = el.$_ptooltipModifiers;
Expand Down Expand Up @@ -106,8 +106,14 @@ function create(el) {
let tooltipText = document.createElement('div');
tooltipText.className = 'p-tooltip-text';

let tooltipLabel = ObjectUtils.htmlEncode(el.$_ptooltipValue);
tooltipText.innerHTML = tooltipLabel;

if (el.$_ptooltipEscape) {
tooltipText.innerHTML = el.$_ptooltipValue;
}
else {
tooltipText.innerHTML = '';
tooltipText.appendChild(document.createTextNode(el.$_ptooltipValue));
}

container.appendChild(tooltipText);
document.body.appendChild(container);
Expand Down Expand Up @@ -285,11 +291,13 @@ const Tooltip = {
else if (typeof options.value === 'string') {
target.$_ptooltipValue = options.value;
target.$_ptooltipDisabled = false;
target.$_ptooltipEscape = false;
target.$_ptooltipClass = null;
}
else {
target.$_ptooltipValue = options.value.value;
target.$_ptooltipDisabled = options.value.disabled || false;
target.$_ptooltipEscape = options.value.escape || false;
target.$_ptooltipClass = options.value.class;
}

Expand All @@ -316,11 +324,13 @@ const Tooltip = {
if (typeof options.value === 'string') {
target.$_ptooltipValue = options.value;
target.$_ptooltipDisabled = false;
target.$_ptooltipEscape = false;
target.$_ptooltipClass = null;
}
else {
target.$_ptooltipValue = options.value.value;
target.$_ptooltipDisabled = options.value.disabled || false;
target.$_ptooltipEscape = options.value.escape || false;
target.$_ptooltipClass = options.value.class;
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/components/utils/ObjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,6 @@ export default {
return null;
},

htmlEncode(str){
if (str) {
return str.replace(/[^\w. ]/gi, function(c){
return '&#'+c.charCodeAt(0)+';';
});
}

return null;
},

isEmpty(value) {
return (
value === null || value === undefined || value === '' ||
Expand Down

0 comments on commit 6424fe3

Please sign in to comment.