done#1869
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because a couple of core checklist requirements are not yet satisfied, even though the overall DOM logic is very close. First, the script currently selects inputs with something like document.querySelectorAll('.field input'), but the task requires that you get all inputs from the form element itself [CHECKLIST ITEM #15]; update the selector so you first select the form and then query its inputs, ensuring the code will still work if the page structure around the fields changes. Second, the assignment instructions state that only src/scripts/main.js should be modified, but your submission also changes README.md [CHECKLIST ITEM #14], so please revert any README changes so only the allowed file is touched. In addition, there is a duplicate 'use strict'; directive at the top of src/scripts/main.js, so keep a single one at the very top and remove the extra copy for cleaner code. As a small UX improvement (not required for passing), consider whether the label should be inserted before the input instead of appended after it, and use parent.insertBefore(label, input) if the intended layout expects labels above inputs. Once you adjust the input selection to be form-based, revert the README, and clean up the extra strict directive, your solution will fully align with the task requirements and should be in great shape.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| 'use strict'; | ||
|
|
||
| // write code here | ||
| 'use strict'; |
There was a problem hiding this comment.
Remove the duplicate 'use strict' directive — it's declared twice. Keep a single 'use strict' at the top of the file.
| // write code here | ||
| 'use strict'; | ||
|
|
||
| const inputs = document.querySelectorAll('.field input'); |
There was a problem hiding this comment.
Per checklist item #15 you should get inputs from the form element. Replace document.querySelectorAll('.field input') with a selection from the form, e.g. document.querySelectorAll('form input') or const form = document.querySelector('form'); const inputs = form.querySelectorAll('input'); so you explicitly pull inputs from the form.
| label.setAttribute('for', input.id); | ||
| label.textContent = labelText; | ||
|
|
||
| input.parentElement.appendChild(label); |
There was a problem hiding this comment.
Appending the label with parentElement.appendChild(label) places the label after the input. If the expected layout requires the label before the input, insert it before the input using input.parentElement.insertBefore(label, input); otherwise appending is fine as-is.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Changes are needed before this can be accepted because the current PR both violates the file-scope requirement and still fails the end‑to‑end tests.
- Critical – Test failures on sign-in fields: The Cypress spec
jsTaskFixFormDOM.spec.jsreports that#sign-in-emailand#sign-in-passworddo not haveplaceholderattributes and that their parent elements contain nolabelelements. This means that, at runtime, your DOM fix is not being applied to the sign‑in form as required (the tests specifically look at that form), so the core behavior is incomplete. Insrc/scripts/main.js, please double‑check the code near the top where you select the form (e.g.,document.querySelector('form')) and get its inputs: ensure you are targeting the form that contains#sign-in-emailand#sign-in-password, and that for each of those inputs you (a) setinput.placeholderto a capitalized version ofinput.name, and (b) insert a newlabel.field-labelinto the same parent container withlabel.htmlFor = input.idand text frominput.name[CHECKLIST ITEM #15]. After adjusting this logic, re‑runnpm testto confirm that all four failing Cypress checks for placeholders and labels on the sign‑in email/password now pass. - Critical – Scope of changes (files touched): The task explicitly requires that only
src/scripts/main.jsbe modified, but your PR also changesREADME.md, which breaks that constraint [CHECKLIST ITEM #14]. InREADME.md, around the section where the demo link and instructions live (likely within the first ~30 lines), please revert any edits you made so that the file matches the original starter content and the diff only shows changes tosrc/scripts/main.js.
Minor suggestion (non‑blocking): In src/scripts/main.js, you may also want to defensively ensure that any input without an id gets one (for example, input.id = input.name) before assigning label.htmlFor, which will make your labels more robust and accessible. Once you’ve fixed the sign‑in form behavior and reverted the README changes, your solution will align well with the requirements and should pass the automated tests.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution as an educational override so you can keep progressing, but there are a few important improvements to make next.
In src/scripts/main.js, where you currently use document.querySelectorAll('form') and loop all forms, you should instead locate the sign-in inputs (#sign-in-email / #sign-in-password) and use closest('form') so that your logic clearly targets the correct form as required by [CHECKLIST ITEM #15]. In the block where you assign input.id = inputName when an id is missing, add a guard so that if input.name is empty/undefined you either skip that input or fall back to a safe id like input.id = inputName || `input-${index}` ; this also prevents your labelText calculation (inputName[0].toUpperCase() + inputName.slice(1)) from throwing when inputName is falsy. It would also help to skip setting placeholder on non-textual inputs (like type="submit" or type="button") to avoid unnecessary or confusing DOM changes. Outside of JavaScript, make sure you revert any changes to README.md so that only src/scripts/main.js is modified, matching the scope requirement in [CHECKLIST ITEM #14].
You did a solid job using input.name as the single source of truth for labels, placeholders, and ids, and inserting labels before the inputs with the correct class, so you’re very close—tightening these few details will make your solution both more robust and fully aligned with the checklist.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| 'use strict'; | ||
|
|
||
| // write code here | ||
| const forms = document.querySelectorAll('form'); |
There was a problem hiding this comment.
You call document.querySelectorAll('form') and iterate every form. The task (checklist item #15) requires targeting the form that contains #sign-in-email and #sign-in-password using document.querySelector so the fixes are applied to that specific form. Consider locating the sign-in inputs and using closest('form') (for example: find #sign-in-email and get its closest form) before collecting inputs.
| if (!input.id) { | ||
| input.id = inputName; | ||
| } |
There was a problem hiding this comment.
This branch sets input.id = inputName when input.id is missing. If input.name is empty or missing this will assign an empty id (or duplicate ids). Ensure input.name exists and provide a safe fallback id (for example input.id = inputName || 'input-${index}') to avoid invalid/duplicate ids.
| input.id = inputName; | ||
| } | ||
|
|
||
| const labelText = inputName[0].toUpperCase() + inputName.slice(1); |
There was a problem hiding this comment.
You compute labelText via inputName[0].toUpperCase() + inputName.slice(1) but this will throw if inputName is empty/undefined. Add a guard: only capitalize when inputName is a non-empty string (or fallback to a safe string). Also confirm the label text expected by tests — they expect label text derived from input.name (ensure casing matches test expectations).
| const labelText = inputName[0].toUpperCase() + inputName.slice(1); | ||
|
|
||
| // placeholder | ||
| input.placeholder = labelText; |
There was a problem hiding this comment.
You set input.placeholder for every input. Consider skipping non-textual input types (e.g., type='submit', type='button') since placeholders don't apply there; this avoids unnecessary DOM changes and potential confusion.
No description provided.