Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code has the condition reversed #34111

Closed
emrys57 opened this issue Jun 13, 2024 · 0 comments · Fixed by #34113
Closed

Example code has the condition reversed #34111

emrys57 opened this issue Jun 13, 2024 · 0 comments · Fixed by #34113
Labels
Content:WebAPI Web API docs good first issue A good issue for newcomers to get started with.

Comments

@emrys57
Copy link

emrys57 commented Jun 13, 2024

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/currentSrc

What specific section or headline is this issue about?

The example section javascript code

What information was incorrect, unhelpful, or incomplete?

p.textContent = clockImage.currentSrc.endsWith("200px.png")
  ? "Using the 400px image!"
  : "Using the 200px image.";
document.body.appendChild(p);

This seems to write "Using the 200px image." if the currentSrc does not end with "200px".

What did you expect to see?

"Using the 400px image!"

Open the clock image on a new tab. It has the 400px URL. Yet the text says 200px.
This behaviour occurs in Firefox and Chrome.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@emrys57 emrys57 added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jun 13, 2024
@github-actions github-actions bot added the Content:WebAPI Web API docs label Jun 13, 2024
@Josh-Cena Josh-Cena added good first issue A good issue for newcomers to get started with. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jun 13, 2024
@Josh-Cena Josh-Cena changed the title Example javascript on MDN seems wrong Example code has the condition reversed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs good first issue A good issue for newcomers to get started with.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants