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

fix object styles not escaped #4887

Merged
merged 6 commits into from
Oct 4, 2022
Merged

fix object styles not escaped #4887

merged 6 commits into from
Oct 4, 2022

Conversation

Calvin-LL
Copy link
Contributor

@Calvin-LL Calvin-LL commented Sep 27, 2022

Changes

Before this PR:

<div
  style={{
    backgroundImage: `url("test.png")`,
  }}
>
</div>

would be rendered as

<div
  style="background-image: url("test.png")"
>
</div>

which is invalid HTML, since the quotes in url are not escaped.

After the fix in this PR, the output is:

<div
  style="background-image: url(&#34;test.png&#34;)"
>
</div>

Also found a bug where shouldEscape isn't passed down to toAttributeString and I fixed it.

Testing

Added astro-object-style test

Docs

Minor fix

@changeset-bot
Copy link

changeset-bot bot commented Sep 27, 2022

🦋 Changeset detected

Latest commit: 882c4c8

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

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 Sep 27, 2022
Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

Looks great, would you mind adding a test? See packages/astro/test/fixture for examples of what our tests look like.

Also a changeset is needed:

pnpm changeset

@Calvin-LL
Copy link
Contributor Author

Calvin-LL commented Sep 27, 2022

Looks great, would you mind adding a test? See packages/astro/test/fixture for examples of what our tests look like.

Also a changeset is needed:

pnpm changeset

Thanks! I've added tests and ran changeset.

Update: just rebased on to the lastest HEAD on main, looks like the HEAD itself isn't passing checks either, will rebase again once fixed

@matthewp
Copy link
Contributor

@Calvin-LL this is just a flakey test. Will rerun and it will likely pass. Thank you!

@matthewp matthewp merged commit 37cb2fc into withastro:main Oct 4, 2022
@astrobot-houston astrobot-houston mentioned this pull request Oct 4, 2022
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.

None yet

2 participants