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

The live samples in some documents seem to be broken #12215

Open
3 tasks done
yin1999 opened this issue Nov 30, 2024 · 1 comment
Open
3 tasks done

The live samples in some documents seem to be broken #12215

yin1999 opened this issue Nov 30, 2024 · 1 comment
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@yin1999
Copy link
Member

yin1999 commented Nov 30, 2024

Summary

Some live samples in "Making decisions in your code — conditionals" seem to be broken.

Check the screenshot section.

URL

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals#active_learning_more_color_choices

Reproduction steps

  1. navigate to the "Active learning: A simple calendar" section
  2. Check the live samples

Expected behavior

The live samples are work well, I've checked the page built by @mdn/[email protected] (run yarn start in mdn/content` folder):

image

Actual behavior

See the screenshot section.

Device

Desktop

Browser

Chrome

Browser version

Stable

Operating system

Linux

Screenshot

image

Anything else?

No response

Validations

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 30, 2024
@fiji-flo
Copy link
Contributor

fiji-flo commented Dec 2, 2024

Thanks for reporting. I didn't expect this worked previously. That's because

<script>
  const script = "<script></script>";
  const h1 = "<h1>H1</h1>";
</script>

will render:
image

We now do real templating so the js parts ends up in a <script> just before the body ends. Allowing real DOM events.

We need to settle on how we want to deal with this. The easiest way is to escape the script tag like:

<script>
  const script = "<script><"+"/script>";
  const h1 = "<h1>H1</h1>";
</script>

or

<script>
  const script = `<script><${"/"}script>`;
  const h1 = "<h1>H1</h1>";
</script>

https://github.com/mdn/content/blob/main/files/en-us/learn/javascript/building_blocks/conditionals/index.md?plain=1#L610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

No branches or pull requests

2 participants