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

more comprehensive property/attribute setting #14

Merged
merged 2 commits into from
Apr 19, 2018
Merged

more comprehensive property/attribute setting #14

merged 2 commits into from
Apr 19, 2018

Conversation

jquense
Copy link
Owner

@jquense jquense commented Dec 19, 2017

@jquense
Copy link
Owner Author

jquense commented Dec 19, 2017

Still a WIP

@jquense jquense changed the base branch from flow to master December 20, 2017 15:45
@jquense jquense changed the title basic controlled component support more comprehensive property/attribute setting Jan 1, 2018
@jquense
Copy link
Owner Author

jquense commented Jan 1, 2018

I did a bunch of work on the prop/attribute stuff and got some SVG support as well. I thought about gating the SVG the support behind a flag so folks that don't need it could be spared the extra weight, but it's not a ton (mostly annoying property configs) so maybe not worth it

plugins.extractText(),
plugins.uglify({ parallel: 4 }),
Copy link
Owner Author

Choose a reason for hiding this comment

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

oops, just a quick test of the DCE

Copy link
Collaborator

@ManasJayanth ManasJayanth Jan 1, 2018

Choose a reason for hiding this comment

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

Sidenote: I have always wondered why it takes three tools: uglify rollup and GCC for DCE.

Copy link
Owner Author

Choose a reason for hiding this comment

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

i guess, GCC probably replaces ugilfy in this case?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess. And rollup does a bit of elimination too. And I'm not talking about tree shaking of ES6. I have seen

if (true) {
// code
}

being turned to

{
// code 
}

by rollup

Copy link
Owner Author

Choose a reason for hiding this comment

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

interesting!

Copy link

Choose a reason for hiding this comment

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

You don’t need Uglify if you use GCC. In fact adding Uglify can make things worse if you have GCC-d code

): boolean {
DOMComponent.setInitialProps(domElement, props);
if (isSvg == null) isSvg = getRootSvgContext(rootContainerInstance);
Copy link
Owner Author

Choose a reason for hiding this comment

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

this feels like it should unnecessary...I wonder if react-reconciler could pass the HostContext here?

We need the context here because unlike react-dom, which has an "attributes first" approach, rdl is "property first" which also means we need to intentionally skip that path for SVGs, hence need to know if we are in an SVG context or not.

@gaearon I took a look at the reconciler code but it wasn't clear (to me) whether passing HostContext is possible at this stage of the commit. Do you have a sense of that?

Copy link

Choose a reason for hiding this comment

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

I think we don’t have host context during the commit phase.

During reconciliation, we go through every host component so we can track it.

During commit, we only go through the fibers marked as having “effects”. It’s a much shorter linked list of things that actually need DOM/lifecycle updates.

So we can’t have the current host context value during the commit because we jump over many nodes.

Copy link

@gaearon gaearon Jan 3, 2018

Choose a reason for hiding this comment

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

Wait, I misunderstood. finalizeInitialChildren is not in the commit phase.

Only things called from CommitWork are commit phase. Things called from BeginWork or CompleteWork are reconciliation phase.

So yes, I think you could pass host context there if you want to. (If the reconciler doesn’t you can send a PR)

@ManasJayanth
Copy link
Collaborator

ManasJayanth commented Jan 4, 2018

I thought about gating the SVG the support behind a flag so folks that don't need it could be spared the extra weight, but it's not a ton (mostly annoying property configs) so maybe not worth it

I think this idea has been floated here before My worry is this would add configuration to the build step. __SVG__ will have to defined during build, right?

@jquense
Copy link
Owner Author

jquense commented Jan 5, 2018

lets just leave off the feature toggling for now. the config doesn't add that much extra, and things like preact already include svg support by default (admittedly it's easier for them because they don't have to normalize prop names)

@jquense
Copy link
Owner Author

jquense commented Mar 20, 2018

gtg?

@nhunzaker
Copy link

nhunzaker commented Apr 4, 2018

@jquense I don't have any more feedback here! I'd be to be a sounding board if you want to flesh out some ideas.

Edit: Also sorry to get to this so late

@jquense jquense merged commit faa9092 into master Apr 19, 2018
@jquense jquense deleted the controlled branch April 19, 2018 13:20
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