Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR removes emoji/log-symbol usage from CI logs, improves numeric parsing of point coordinates with locale-agnostic handling, hardens toast creation when the expected container is missing, and refactors cursor coordinate rendering to use safe DOM APIs instead of innerHTML. Sequence diagram for locale-agnostic point parsingsequenceDiagram
participant UserInput as User
participant AppPoints as AppPoints
participant readPoint as readPoint
UserInput->>AppPoints: set ix.value, iy.value
AppPoints->>readPoint: readPoint(ix, iy)
activate readPoint
readPoint->>readPoint: String(ix.value).replace(',', '.')
readPoint->>readPoint: parseFloat(gx)
readPoint->>readPoint: String(iy.value).replace(',', '.')
readPoint->>readPoint: parseFloat(gy)
alt [isNaN(gx) or isNaN(gy)]
readPoint-->>AppPoints: null
else
readPoint-->>AppPoints: { x: gx, y: gy, ... }
end
deactivate readPoint
Sequence diagram for toast creation with fallback containersequenceDiagram
participant AppShare as AppShare
participant document as document
participant toast as toastDiv
AppShare->>AppShare: showToast(message, type)
alt [toast element exists]
AppShare->>toast: update textContent, className
else [toast element missing]
AppShare->>document: createElement('div')
document-->>AppShare: toastDiv
AppShare->>toast: set id, className
AppShare->>document: querySelector('.map-wrap')
alt [wrap found]
document-->>AppShare: wrap
else [wrap missing]
document-->>AppShare: body
end
AppShare->>wrap: appendChild(toastDiv)
AppShare->>toast: set textContent, className
end
Sequence diagram for safe cursor coordinate renderingsequenceDiagram
participant MapInt as MapInteractions
participant utils as utils
participant cursor as cursorCoords
MapInt->>MapInt: handleMouseMove(p, view)
MapInt->>document: getElementById('cursorCoords')
document-->>MapInt: cursorCoords
alt [cursorCoords exists]
MapInt->>utils: screenToWorld(p.x, p.y, view)
utils-->>MapInt: wpt
MapInt->>cursor: set textContent = ''
MapInt->>document: createElement('span')
document-->>MapInt: xSpan
MapInt->>xSpan: set textContent = 'x' + utils.gameCoord(wpt.x)
MapInt->>document: createElement('span')
document-->>MapInt: ySpan
MapInt->>ySpan: set textContent = 'y' + utils.gameCoord(wpt.y)
MapInt->>cursor: appendChild(xSpan)
MapInt->>cursor: appendChild(ySpan)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
Fixed security issues:
-
Cross-site scripting (XSS) via untrusted HTML/JS injection in web rendering sinks (link)
-
The coordinate parsing in
readPointis now duplicated forgxandgy; consider extracting a small helper (e.g.parseLocalizedFloat(input)) to keep this logic in one place and easier to reuse or adjust. -
In
updateCursorCoords, new span elements are created and appended on every mouse move; you could improve performance by creating the spans once and only updating theirtextContent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The coordinate parsing in `readPoint` is now duplicated for `gx` and `gy`; consider extracting a small helper (e.g. `parseLocalizedFloat(input)`) to keep this logic in one place and easier to reuse or adjust.
- In `updateCursorCoords`, new span elements are created and appended on every mouse move; you could improve performance by creating the spans once and only updating their `textContent`.
## Individual Comments
### Comment 1
<location path="js/map/interactions.js" line_range="115-121" />
<code_context>
if (cursorCoords) {
const wpt = utils.screenToWorld(p.x, p.y, view);
- cursorCoords.innerHTML = `<span>x${utils.gameCoord(wpt.x)}</span><span>y${utils.gameCoord(wpt.y)}</span>`;
+ cursorCoords.textContent = '';
+ const xSpan = document.createElement('span');
+ xSpan.textContent = `x${utils.gameCoord(wpt.x)}`;
+ const ySpan = document.createElement('span');
+ ySpan.textContent = `y${utils.gameCoord(wpt.y)}`;
+ cursorCoords.appendChild(xSpan);
+ cursorCoords.appendChild(ySpan);
const wrap = canvas.parentElement.getBoundingClientRect();
let lx = p.x + 14;
</code_context>
<issue_to_address>
**suggestion (performance):** Avoid allocating new span elements on every mouse move to reduce DOM churn.
Since this runs on every mouse move, repeatedly creating and appending new spans can add unnecessary DOM churn and GC pressure. Consider creating the spans once and just updating their `textContent` to improve responsiveness, particularly on lower-end devices.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| cursorCoords.textContent = ''; | ||
| const xSpan = document.createElement('span'); | ||
| xSpan.textContent = `x${utils.gameCoord(wpt.x)}`; | ||
| const ySpan = document.createElement('span'); | ||
| ySpan.textContent = `y${utils.gameCoord(wpt.y)}`; | ||
| cursorCoords.appendChild(xSpan); | ||
| cursorCoords.appendChild(ySpan); |
There was a problem hiding this comment.
suggestion (performance): Avoid allocating new span elements on every mouse move to reduce DOM churn.
Since this runs on every mouse move, repeatedly creating and appending new spans can add unnecessary DOM churn and GC pressure. Consider creating the spans once and just updating their textContent to improve responsiveness, particularly on lower-end devices.
Summary by Sourcery
Improve coordinate input and sharing robustness while making cursor coordinate rendering safer.
Bug Fixes:
CI: