-
Notifications
You must be signed in to change notification settings - Fork 1
Harden string-based rendering #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,17 +164,27 @@ | |
| var frappeTasks = tasksToFrappe(taskList); | ||
|
|
||
| if (frappeTasks.length === 0) { | ||
| chartContainer.innerHTML = '<div style="padding:24px;color:var(--sf-gray-400);font-family:var(--sf-font-mono);font-size:13px;">No scheduled tasks to display.</div>'; | ||
| chartContainer.textContent = ''; | ||
| chartContainer.appendChild(sf.el('div', { | ||
| className: 'sf-gantt-empty-state', | ||
| style: { | ||
| padding: '24px', | ||
| color: 'var(--sf-gray-400)', | ||
| fontFamily: 'var(--sf-font-mono)', | ||
| fontSize: '13px', | ||
| }, | ||
| }, 'No scheduled tasks to display.')); | ||
| ganttChart = null; | ||
| return; | ||
| } | ||
|
|
||
| chartContainer.innerHTML = '<svg id="' + svgId + '"></svg>'; | ||
| chartContainer.textContent = ''; | ||
| chartContainer.appendChild(sf.el('svg', { id: svgId })); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Replacing the parser-created Useful? React with 👍 / 👎. |
||
|
|
||
| ganttChart = new Gantt('#' + svgId, frappeTasks, { | ||
| view_mode: viewSelect.value || 'Quarter Day', | ||
| date_format: 'YYYY-MM-DD HH:mm', | ||
| custom_popup_html: config.popupHtml || defaultPopup, | ||
| custom_popup_html: config.unsafePopupHtml || config.popupHtml || defaultPopup, | ||
| on_click: function (task) { | ||
| ctrl.highlightTask(task.id); | ||
| if (config.onTaskClick) config.onTaskClick(task); | ||
|
|
@@ -186,7 +196,7 @@ | |
| } | ||
|
|
||
| function renderGrid(taskList) { | ||
| grid.innerHTML = ''; | ||
| while (grid.firstChild) grid.removeChild(grid.firstChild); | ||
| var table = sf.el('table', { className: 'sf-gantt-table' }); | ||
|
|
||
| // Header | ||
|
|
@@ -221,7 +231,8 @@ | |
| td.textContent = task.name || task.label || task.id; | ||
| } else if (col.render) { | ||
| var content = col.render(task); | ||
| if (typeof content === 'string') td.innerHTML = content; | ||
| if (typeof content === 'string') td.textContent = content; | ||
| else if (content && content.unsafeHtml) td.innerHTML = content.unsafeHtml; | ||
| else if (content instanceof Node) td.appendChild(content); | ||
| } else { | ||
| td.textContent = task[col.key] || ''; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsafeBodyas raw HTML in modal helperThe new modal API advertises
unsafeBodyas the opt-in HTML hook, but this helper only switches toinnerHTMLwhencontent.unsafeHtmlexists. If a consumer follows the new API and passesunsafeBody: '<strong>...</strong>', the markup is still written throughtextContent, so both the initial modal body and any latersetBody()updates render the literal tags instead of HTML.Useful? React with 👍 / 👎.