Skip to content

avoid touching dom-attributes during hydration#2679

Merged
JoviDeCroock merged 2 commits intomasterfrom
hydrate-options-issue
Aug 4, 2020
Merged

avoid touching dom-attributes during hydration#2679
JoviDeCroock merged 2 commits intomasterfrom
hydrate-options-issue

Conversation

@JoviDeCroock
Copy link
Copy Markdown
Member

Fixes #2678

I broke this in https://github.com/preactjs/preact/pull/2551/files#diff-a04f8653407a342eac2cd2ea6a5c3ff6R186

render-to-string already sets these values correctly and we shouldn't double touch it

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 4, 2020

Size Change: +13 B (0%)

Total Size: 40.3 kB

Filename Size Change
dist/preact.js 3.97 kB +4 B (0%)
dist/preact.min.js 3.99 kB +2 B (0%)
dist/preact.module.js 3.98 kB +4 B (0%)
dist/preact.umd.js 4.03 kB +3 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.25 kB 0 B
compat/dist/compat.module.js 3.28 kB 0 B
compat/dist/compat.umd.js 3.31 kB 0 B
debug/dist/debug.js 3.01 kB 0 B
debug/dist/debug.module.js 3 kB 0 B
debug/dist/debug.umd.js 3.1 kB 0 B
devtools/dist/devtools.js 185 B 0 B
devtools/dist/devtools.module.js 195 B 0 B
devtools/dist/devtools.umd.js 261 B 0 B
hooks/dist/hooks.js 1.1 kB 0 B
hooks/dist/hooks.module.js 1.12 kB 0 B
hooks/dist/hooks.umd.js 1.18 kB 0 B
test-utils/dist/testUtils.js 437 B 0 B
test-utils/dist/testUtils.module.js 439 B 0 B
test-utils/dist/testUtils.umd.js 515 B 0 B

compressed-size-action

@coveralls
Copy link
Copy Markdown

coveralls commented Aug 4, 2020

Coverage Status

Coverage remained the same at 99.8% when pulling 2001d64 on hydrate-options-issue into 3ce11bc on master.

Comment thread src/diff/children.js Outdated
// To fix it we make sure to reset the inferred value, so that our own
// value check in `diff()` won't be skipped.
if (newParentVNode.type == 'option') {
if (newParentVNode.type == 'option' && !isHydrating) {
Copy link
Copy Markdown
Member

@developit developit Aug 4, 2020

Choose a reason for hiding this comment

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

I think reversing the conditions here so the isHydrating check comes first will reduce the size to ~0. Terser will minify it to something like:

if (isHydrating) {}
else if (...) {}

@JoviDeCroock JoviDeCroock merged commit 82bcc15 into master Aug 4, 2020
@JoviDeCroock JoviDeCroock deleted the hydrate-options-issue branch August 4, 2020 16:54
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.

Preact removes option values on hydration

3 participants