Skip to content

Commit

Permalink
Backport #3568 (Read from textContent rather than innerHTML during re…
Browse files Browse the repository at this point in the history
…hydrate) to v5 (#3591)

* Backport #3568 to v5

* Describe innerHTML to textContent change

Co-authored-by: Keegan Street <keegan.street@rea-group.com>
  • Loading branch information
keeganstreet and Keegan Street committed Oct 19, 2021
1 parent 5aa0af3 commit 6e7ac64
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 6e7ac64

Please sign in to comment.