fix: remove embedded HTML script tags and fix global total bug in cart.js - #950
Open
saurabhhhcodes wants to merge 1 commit into
Open
fix: remove embedded HTML script tags and fix global total bug in cart.js#950saurabhhhcodes wants to merge 1 commit into
saurabhhhcodes wants to merge 1 commit into
Conversation
…lation bug in cart.js - Remove embedded <script> HTML tags from .js file that caused syntax errors and prevented lazy-loading code from executing - Fix global total variable that accumulated across multiple calculateBill() calls; now uses local variable and reads bill text for order validation
There was a problem hiding this comment.
Great job, @saurabhhhcodes! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project.We will promptly review your changes and offer feedback. Keep up the excellent work!
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.
Bugs Fixed
1. Embedded
<script>HTML tags in.jsfilecart.jscontained raw<script>and</script>HTML tags (lines 77-100) which are invalid JavaScript syntax. When the browser loads this file, it throws aSyntaxErrorat the<script>token, preventing all lazy-loading and image optimization code from running.Fix: Removed the HTML
<script>/</script>wrapper, leaving valid JavaScript code.2. Global
totalvariable accumulates acrosscalculateBill()callsThe
totalvariable was declared globally but never reset, causing the bill amount to grow on every call.Fix: Made
totala local variable insidecalculateBill(). Updated the order button handler to read the current total from the DOM instead of relying on a stale global.