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

Deprecate unescaped HTML inside of expressions #2489

Merged
merged 10 commits into from
Jan 31, 2022
Merged

Conversation

natemoo-re
Copy link
Member

@natemoo-re natemoo-re commented Jan 28, 2022

Changes

  • Does not require compiler changes!

  • Deprecates passing unescaped HTML inside of an expression (like {"<style>div { color: red; }</style>"}, logs a warning when unescaped HTML is encountered
    Screen Shot 2022-01-28 at 2 22 23 PM

  • Does NOT enable automatic escaping inside of expressions! This is a simple toggle that can be enabled in a follow-up PR to be released in the next minor version.

  • Adds an internal UnescapedString primitive to power set:html and internal rendering

Testing

Tested manually in the examples.

TODO: ensure all examples are working as expected.

Docs

TBD.

@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2022

🦋 Changeset detected

Latest commit: cb50e61

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 28, 2022
@netlify
Copy link

netlify bot commented Jan 28, 2022

✔️ Deploy Preview for astro-docs-2 ready!

🔨 Explore the source changes: cb50e61

🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61f85cb2a7982f00079d71a8

😎 Browse the preview: https://deploy-preview-2489--astro-docs-2.netlify.app

@natemoo-re natemoo-re changed the title [WIP] Deprecate unescaped HTML inside of expressions Deprecate unescaped HTML inside of expressions Jan 28, 2022
@boehs
Copy link
Contributor

boehs commented Jan 28, 2022

Is there really a point of referencing something that does not exist? It can always be added at a later date.

@natemoo-re natemoo-re marked this pull request as ready for review January 31, 2022 20:59
@@ -41,4 +41,4 @@ if (content) {
html = htmlContent;
---

{html ? html : <slot />}
{html ? <Fragment set:html={html} /> : <slot />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@natemoo-re natemoo-re force-pushed the feat/automatic-escaping branch from 459bb28 to cb50e61 Compare January 31, 2022 22:03
@natemoo-re natemoo-re merged commit 618a16f into main Jan 31, 2022
@natemoo-re natemoo-re deleted the feat/automatic-escaping branch January 31, 2022 22:13
@github-actions github-actions bot mentioned this pull request Jan 31, 2022
@github-actions github-actions bot mentioned this pull request Feb 18, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* feat: implement automatic escaping

* feat: deprecate automatic escaping

* fix: cast unescapeHTML as string

* fix: slot fallback behavior

* fix: unescaped content

* Update escape.ts

* Update escape.ts

* feat: update internal components to use `set:html`

* chore: update compiler

* chore: update changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants