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: hydrate node with dangerouslySetInnerHTML #1957

Merged
merged 5 commits into from
Jul 21, 2020
Merged

Conversation

chenjun1011
Copy link
Collaborator

When hydrate node with dangerouslySetInnerHTML :

<div className="container" dangerouslySetInnerHTML={{__html: `<div>About Rax</div><div>Docs</div>`}} />

It will trigger recolectHydrationChild and clear innerHtml.

Result is <div class="container"></div> rather than <div class="container" ><div>About Rax</div><div>Docs</div></div>

@@ -118,4 +118,18 @@ describe('Hydrate', () => {

expect(container.childNodes[0].childNodes[2].tagName).toBe('DIV');
});

it('should not recolect hydration child with innerHtml', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

recolect 是不是拼错了

@@ -118,4 +118,18 @@ describe('Hydrate', () => {

expect(container.childNodes[0].childNodes[2].tagName).toBe('DIV');
});

it('should not recolect hydration child with innerHtml', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

innerHtml -> innerHTML

@@ -429,6 +435,11 @@ export function beforeRender({ hydrate }) {
}

function recolectHydrationChild(hydrationParent) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

image
这个单词是不是拼错了?

Copy link
Collaborator

Choose a reason for hiding this comment

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

而且回忆,反思 也有点奇怪

@wssgcg1213
Copy link
Collaborator

逻辑上OK

@imsobear imsobear merged commit 7d44828 into master Jul 21, 2020
@imsobear imsobear deleted the fix-hydrate-html branch July 21, 2020 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants