Skip to content

Commit

Permalink
short desc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TalmizAhmed committed Apr 23, 2024
1 parent abfe57e commit 790550f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blocks/form/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const createTextArea = withFieldWrapper((fd) => {
const createSelect = withFieldWrapper((fd) => {
const select = document.createElement('select');
select.required = fd.required;
select.title = fd.tooltip ?? '';
select.title = stripTags(fd.tooltip, '') ?? '';
select.readOnly = fd.readOnly;
select.multiple = fd.type === 'string[]' || fd.type === 'boolean[]' || fd.type === 'number[]';
let ph;
Expand Down
9 changes: 6 additions & 3 deletions blocks/form/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ export function stripTags(input, allowd = allowedTags) {
.join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>)
const tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;
const comments = /<!--[\s\S]*?-->/gi;
const nbsp = /&nbsp;/g; // nbsp: non-breaking space character
return input.replace(comments, '')
.replace(tags, ($0, $1) => (allowed.indexOf(`<${$1.toLowerCase()}>`) > -1 ? $0 : ''));
.replace(tags, ($0, $1) => (allowed.indexOf(`<${$1.toLowerCase()}>`) > -1 ? $0 : ''))
.replace(nbsp, '')
.trim();
}

/**
Expand Down Expand Up @@ -66,8 +69,8 @@ export function createLabel(fd, tagName = 'label') {
if (fd.label.visible === false) {
label.dataset.visible = 'false';
}
if (fd.Tooltip) {
label.title = fd.Tooltip;
if (fd.tooltip) {
label.title = stripTags(fd.tooltip, '');
}
return label;
}
Expand Down

0 comments on commit 790550f

Please sign in to comment.