Skip to content

Consolidate VNode compat options (-62 B)#2116

Merged
marvinhagemeister merged 6 commits into
masterfrom
feat/simplify-compat
Nov 13, 2019
Merged

Consolidate VNode compat options (-62 B)#2116
marvinhagemeister merged 6 commits into
masterfrom
feat/simplify-compat

Conversation

@andrewiggins

Copy link
Copy Markdown
Member

Currently the compat src has VNode compat functions spread across a couple different functions making it hard to modify (should I add it normalizeVNode? createElement? handleElementVNode?).

This PR simplifies VNode compat by inline all of those disparate functions into the options.vnode hook. Every vnode that is created (including cloneElement) goes through this options hook so it guarantees VNode compat is consistently applied.

Also saves some bytes!

Comment thread compat/src/index.js Outdated
}

// TODO: Removing this saves 16 bytes!
vnode.preactCompatNormalized = true;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Anyone know if we need to support this property? Or can we remove it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I vote for removing it, it's unused and don't really see a use case for it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed. Since this comment is now outdated (which I think means it'll be collapsed for some), I made a new comment for others to see and discuss.

@andrewiggins andrewiggins changed the title Consolidate VNode compat options (-47 B) Consolidate VNode compat options (-62 B) Nov 13, 2019
Comment thread compat/src/index.js
* @param {import('./internal').VNode} vnode
*/
function normalizeVNode(vnode) {
vnode.preactCompatNormalized = true;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just calling that I removed this property cuz I don't think it's being used anymore. Holler if you think this is worth the 16 bytes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Iirc this is a leftover from earlier iterations. Previous versions would check for this property and only normalize a vnode if it was missing.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 100.0% when pulling cfae34d on feat/simplify-compat into 95b7924 on master.

@marvinhagemeister marvinhagemeister left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So good 🙌💯 It makes the code a lot easier to read 👍

@marvinhagemeister marvinhagemeister merged commit d16f15c into master Nov 13, 2019
@marvinhagemeister marvinhagemeister deleted the feat/simplify-compat branch November 13, 2019 06:31
@cristianbote

Copy link
Copy Markdown
Member

Great work @andrewiggins! 🎉

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.

5 participants