Fixed so that tagify tooltip descriptions cannot end up with raw HTML that breaks it (#1504)

This commit is contained in:
WBHarry 2026-01-09 15:57:57 +01:00 committed by GitHub
parent 6cebccd958
commit bbe8fb953e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -119,7 +119,7 @@ export const tagifyElement = (element, baseOptions, onChange, tagifyOptions = {}
spellcheck='false'
tabIndex="${this.settings.a11y.focusableTags ? 0 : -1}"
class="${this.settings.classNames.tag} ${tagData.class ? tagData.class : ''}"
data-tooltip="${tagData.description || tagData.name}"
data-tooltip="${tagData.description ? htmlToText(tagData.description) : tagData.name}"
${this.getAttributes(tagData)}>
<x class="${this.settings.classNames.tagX}" role='button' aria-label='remove tag'></x>
<div>
@ -198,7 +198,7 @@ foundry.dice.terms.Die.prototype.selfCorrecting = function (modifier) {
};
export const getDamageKey = damage => {
return ['none', 'minor', 'major', 'severe', 'massive','any'][damage];
return ['none', 'minor', 'major', 'severe', 'massive', 'any'][damage];
};
export const getDamageLabel = damage => {
@ -474,3 +474,10 @@ export async function getCritDamageBonus(formula) {
const critRoll = new Roll(formula);
return critRoll.dice.reduce((acc, dice) => acc + dice.faces * dice.number, 0);
}
export function htmlToText(html) {
var tempDivElement = document.createElement('div');
tempDivElement.innerHTML = html;
return tempDivElement.textContent || tempDivElement.innerText || '';
}