Skip to content

Commit

Permalink
Backport styled-components#3568 (Read from textContent rather than in…
Browse files Browse the repository at this point in the history
…nerHTML during rehydrate) to v5 (styled-components#3591)

* Backport styled-components#3568 to v5

* Describe innerHTML to textContent change

Co-authored-by: Keegan Street <keegan.street@rea-group.com>
  • Loading branch information
2 people authored and Andrija Plavsa committed Mar 3, 2022
1 parent ec9bed3 commit 771f936
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ _The format is based on [Keep a Changelog](http://keepachangelog.com/) and this

## Unreleased

- Rehydrate stylesheets from `textContent` rather than `innerHTML` to fix issue of selectors sometimes being HTML encoded (see [#3567](https://github.com/styled-components/styled-components/issues/3567)).

## [v5.3.1] - 2021-08-24

- Fix forced server-side mode not triggering global styles (See [#3566](https://github.com/styled-components/styled-components/pull/3566))
Expand Down
2 changes: 1 addition & 1 deletion packages/styled-components/src/sheet/Rehydration.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const rehydrateNamesFromContent = (sheet: Sheet, id: string, content: string) =>
};

const rehydrateSheetFromTag = (sheet: Sheet, style: HTMLStyleElement) => {
const parts = (style.innerHTML || '').split(SPLITTER);
const parts = (style.textContent || '').split(SPLITTER);
const rules: string[] = [];

for (let i = 0, l = parts.length; i < l; i++) {
Expand Down

0 comments on commit 771f936

Please sign in to comment.