Skip to content

Commit f7d1ee9

Browse files
committed
Render labels and links as HTML in preview
Replace textContent with innerHTML for various UI elements in plugins/experimentation/src/preview.js so labels and action link labels can contain HTML markup. Affected functions: createButton, createPopupItem, createPopupDialog, and createToggleButton. Also minor whitespace cleanups around link/button creation.
1 parent cb23d46 commit f7d1ee9

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

plugins/experimentation/src/preview.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function createButton(label) {
5353
const button = document.createElement('button');
5454
button.className = 'hlx-badge';
5555
const text = document.createElement('span');
56-
text.textContent = label;
56+
text.innerHTML = label;
5757
button.append(text);
5858
return button;
5959
}
@@ -64,7 +64,7 @@ function createPopupItem(item) {
6464

6565
const label = document.createElement('h5');
6666
label.className = 'hlx-popup-item-label';
67-
label.textContent = typeof item === 'object' ? item.label : item;
67+
label.innerHTML = typeof item === 'object' ? item.label : item;
6868
div.appendChild(label);
6969

7070
if (item.description) {
@@ -89,16 +89,16 @@ function createPopupItem(item) {
8989

9090
const link = document.createElement('a');
9191
link.href = action.href || '#';
92-
link.textContent = action.label;
93-
92+
link.innerHTML = action.label;
93+
9494
if (action.onclick) {
9595
link.addEventListener('click', action.onclick);
9696
}
97-
97+
9898
buttonDiv.appendChild(link);
9999
actionsDiv.appendChild(buttonDiv);
100100
});
101-
101+
102102
div.appendChild(actionsDiv);
103103
}
104104

@@ -120,7 +120,7 @@ function createPopupDialog(header, items = []) {
120120

121121
const headerLabel = document.createElement('h5');
122122
headerLabel.className = 'hlx-popup-header-label';
123-
headerLabel.textContent = typeof header === 'object' ? header.label : header;
123+
headerLabel.innerHTML = typeof header === 'object' ? header.label : header;
124124
headerDiv.appendChild(headerLabel);
125125

126126
if (header.description) {
@@ -144,12 +144,12 @@ function createPopupDialog(header, items = []) {
144144

145145
const link = document.createElement('a');
146146
link.href = action.href || '#';
147-
link.textContent = action.label;
148-
147+
link.innerHTML = action.label;
148+
149149
if (action.onclick) {
150150
link.addEventListener('click', action.onclick);
151151
}
152-
152+
153153
buttonDiv.appendChild(link);
154154
headerActions.appendChild(buttonDiv);
155155
});
@@ -197,7 +197,7 @@ function createToggleButton(label) {
197197
button.setAttribute('aria-pressed', false);
198198
button.setAttribute('tabindex', 0);
199199
const text = document.createElement('span');
200-
text.textContent = label;
200+
text.innerHTML = label;
201201
button.append(text);
202202
button.addEventListener('click', () => {
203203
button.setAttribute('aria-pressed', button.getAttribute('aria-pressed') === 'false');

0 commit comments

Comments
 (0)