fix: define renderCodeWithLineNumbers in script.js to resolve ReferenceError#436
fix: define renderCodeWithLineNumbers in script.js to resolve ReferenceError#436anshul23102 wants to merge 1 commit into
Conversation
|
@anshul23102 is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@komalharshita this PR is ready for review and all CI checks pass. Could you please add the relevant labels? It helps with tracking. Thank you! |
|
Hi @komalharshita, just a gentle follow-up on this PR. It has been about 5 days and the branch is clean with no CI failures or conflicts. Please let me know if you would like any changes. Thank you for your time! |
komalharshita
left a comment
There was a problem hiding this comment.
Thank you for the contribution.
I reviewed the changes and verified that this PR directly addresses the reported ReferenceError caused by the missing renderCodeWithLineNumbers() function.
The implementation is focused, follows the existing DOM structure and CSS class conventions, and safely renders code content using textContent. This restores the View Code functionality and prevents the runtime error from occurring when opening starter code panels.
The fix is clear, low-risk, and scoped appropriately to the linked issue.
Looks good to me and is ready to be merged after resolving the merge conflicts with the latest main branch.
…or on detail pages The code viewer panel called renderCodeWithLineNumbers(data.code) at line 763 of script.js, but this function was never defined anywhere in the codebase. Every click on the View Code or View Code (mobile) button produced a ReferenceError in the browser console and the code panel rendered empty. Add renderCodeWithLineNumbers(code) adjacent to fetchStarterCode. It splits the code string into lines and returns an array of DOM row elements, each containing a line-number gutter cell and a content cell. Using document.createElement and textContent instead of innerHTML ensures the code content is never parsed as markup. Closes komalharshita#406
d131abd to
f8d5f42
Compare
Description
The code viewer panel on detail pages called
renderCodeWithLineNumbers(data.code)but this function was never defined anywhere in the codebase. Every click on the View Code or View Code (mobile) button threw aReferenceErrorin the browser console and the code panel rendered empty.Root Cause
Related Issue
Closes #406
Type of Change
Changes Made
static/script.js:renderCodeWithLineNumbers(code)function inside the detail-page block, adjacent tofetchStarterCode..code-line-number) and a content cell (.code-line-content).document.createElementandtextContentinstead ofinnerHTMLso the code content is never parsed as markup.Testing Done
Checklist