Fix typos in hero subtitle and card title#21
Open
Adir-html wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed spelling for HTML.
This PR addresses an issue where the addEventOnElem utility function incorrectly handled the window object due to an unreliable check for the .length property.
The Problem:
The original code used if (elem.length > 1) to determine if the input was a collection of elements. However:
Window Object Trap: In browsers, window.length returns the number of iframes on the page. If a page has 0 or 1 iframes, the function worked by accident. If a page had 2+ iframes, the function would attempt to loop through them instead of attaching the event to the window itself, breaking features like scroll-based header animations.
Logic Flaw: Checking for .length > 1 is a "leaky" way to detect arrays or NodeLists.
The Fix:
I have refactored addEventOnElem to use more explicit type checking:
It now checks if the element is an instanceof NodeList or Array.isArray().
This ensures that collections are always looped through correctly, while single objects (like window or individual HTMLElements) are handled by the fallback else block.
Changes:
Updated addEventOnElem logic in script.js.
Verified that navbar toggles (NodeLists) and window scrolling (Object) both function correctly after the change.