-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Simplified/improved custom rendering of virtual nodes: removed hpass
and VirtualElementPass
, added optional renderer
param
#44
Conversation
- build of @lumino/widgets currently broken, still need to: - add fixes to widgets (title and tabbar) - fix unittests in virtualdom pkg
Here's what's left for WIP:
The PR is now done! @blink1073 @vidartf (or anyone else who feels like it): can you please review? I'd like to get this pulled in so that I can add some relevant changes to jlab before the 2.0 release. There's a minor stylistic flaw that I'm unsure how to resolve. There doesn't seem to be a good way to add the lumino/packages/virtualdom/src/index.ts Line 754 in 6282805
lumino/packages/virtualdom/src/index.ts Lines 843 to 846 in 6282805
Previously, there was a nice symmetry between the signatures of lumino/packages/virtualdom/src/index.ts Line 745 in 5041edd
lumino/packages/virtualdom/src/index.ts Lines 846 to 847 in 5041edd
Basically, I can't put Another possibility would be use a custom argument resolution scheme in Some external input on the issue would be most appreciated |
h
and VirtualElementPass
, added optional renderer
paramh
and VirtualElementPass
, added optional renderer
param
h
and VirtualElementPass
, added optional renderer
paramh
and VirtualElementPass
, added optional renderer
param
h
and VirtualElementPass
, added optional renderer
paramhpass
and VirtualElementPass
, added optional renderer
param
- needed to add new `h` signature overloads to the `h.IFactory` interface
…derers - still need to actually try running the tests
hpass
and VirtualElementPass
, added optional renderer
paramhpass
and VirtualElementPass
, added optional renderer
param
I looked, and to my surprise there do appear to be 4 external projects that depend on the exact signature of On the other hand, there's a ton of projects that import |
- related to code added to @lumino/virtualdom in jupyterlab/lumino#44. Once that's pulled in, the TODOs added in this PR will then be able to be cleared
I think we should save API changes for a major release of the virtualdom package, for jlab 3.0. |
Which API changes do you mean?
The removals in 1) were technically breaking, which yeah, even if nobody's using them probably still isn't a great idea. I just added a backwards compatibility shim that provides them. EditOhhh, you were responding to my comment about splitting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @telamonian, this is a nice enhancement and cleanup. I left one comment. I am traveling this morning, but should be able to get this merged and released later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Published |
Sweet. Thanks @blink1073! |
This PR contains a massive simplification and a number of improvements to the implementation of virtual nodes with custom renderers (formerly known as "passthru" virtual nodes) in the virtualdom pkg.
Ideally this PR will get pulled in sometime in the next week. so that I can incorporate its improvements into jlab before the 2.0 release, since it may involve some breaking changes in jlab (see note bellow about breaking changes w.r.t. lumino).
Overview of changes:
I removed
VirtualElementPass
andhpass
and folded their implementations intoVirtualElement
andh
. A custom renderer (what I had formerly been calling a "passthru" renderer) can now be set on any virtual node via an optional arg to eitherVirtualElement
orh
. This has a number of benefits:implementation
renderer
is now an optional property for bothh
andnew VirtualElement
. Sincerenderer
is optional, backwards compatibility is preserved for these functions.it is now possible for a node to have both a custom renderer and children.When node.renderer.render is called, the node's .attr and .children fields will be passed as options. The render function will then be able to create actual DOM children based on the passed .children field. If the particular render function being used does not support .children, it will just be ignored
I fixed up and added to all of the related docstrings, with the goal in mind of making it easier to understand what a
VirtualElement.IRenderer
actually is and does. Hopefully that will make it easier for people to create and use their own custom element renderersTechnically, this PR includes breaking changes in the form of the removal of
hpass
andVirtualElementPass
. However, a search of github reveals that there is currently 0% adoption of eitherhpass
orVirtualElementPass
(aside from my own work in jlab core), so I think this will be safe to pull in.update
This PR now also includes a fix for a minor problem with tabbar icons. Previously, when
title.iconRenderer
was set,title.iconLabel
would get set as the title attribute of the icon's DOM element. This was not correct.Instead,
.iconLabel
will now be treated the same regardless of the presence of.iconRenderer
:.iconLabel
will be set as a child of the virtual element corresponding to the icon. If.iconRenderer
is set, it's then the responsibility of.iconRenderer.render
whether and how to create the actual DOM corresponding to.iconLabel
.