-
Notifications
You must be signed in to change notification settings - Fork 180
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
[question] Can I have more than one version of incremental dom on the same page? #254
Comments
Not currently. We have a ticket to make iDOM configure instances instead of the class definition. (On a phone now, can't find it…) |
In #114 (comment) you mention:
I couldn't find any other issues related to this. I've also commented there. It'd be rad to be able to do that. I'm happy to do whatever I can to help (including PR'ing it). |
PRs, welcome. 😁 I think the best path would be to be able to pass patching options into |
Looking at the code, it looks like the only configuration that has side effects are I'll see if I can find some time later today or this week to start some work on that. |
@jridgewell we've started running into problems with this so I might start dev on it soon. Do you pefer to not make this a breaking change? For example, we can probably inject the relevant stuff into the patch() functions while still keeping the globals, or would you prefer to clean up the API and have one way of doing things? I vote for the latter. Maybe @sparhami would have some input here, too. |
I'm looking at allowing patch take a config object for the attributes config. For the change notifications, I'm thinking of taking them out of the core library and creating a helper that uses MutationObserver (or monkey patches the few DOM operations Incremental DOM uses if it is not available). |
As in you've already started working on it, or plan to? Just don't want to double up on any work. I think I could probably successfully move things to patch() for now, but it sounds like you have other ideas in your head for the MO approach. |
I have the pieces for the mutation observer approach for creation/removal notifications. Let me get that out of the way real quick, since that reduces the amount of changes needed to patch to support multiple instances. |
👍 thanks @sparhami. When that's done I'll work on attributes. |
For now I just removed the notification hooks. For attributes, I'm looking at adding a few new APIs: I'm going to be somewhat relying on dead-code elimination from the consumers of Incremental DOM to get the optimal size since that should be more common these days.
The attribute APIs may or may not have a callback to format the value when the data changes. Still thinking through this one. From some exploration work, I have found that separating out the calls could be an improvement for performance. The The new API will likely batch changes at the end of the patch (or perhaps outermost patch) by default. There will be a |
OOC, how did you determine this? |
Does this mean you'll also rename Would the How does I really like the idea of using objects. Sorry about all the questions, this looks like a great path for iDOM :) |
I have some personal branches where I experiment on ideas with some simplifications and differences to the core parts of Incremental DOM that I am thinking about. The simplifications make changes and playing with different ideas easier. Two relevant branches I have are: https://github.com/sparhami/incremental-dom/tree/explore_batch with the difference being: I'm just looking at the two tests in the perf directory for now. Running both in a clean profile, I get the following numbers rather consistently for the 'list' test. The high mutation one is more bound by the number of attribute updates going on. As an aside, I found that I need to restart Chrome when switching branches since refreshing the page changes the numbers quite a bit. explore_batch: 170-174ms Not a huge difference. I will been happy with even a small performance hit. Need to dig more into why this is. It could be something about how the variable arguments work in the This doesn't stay consistent when doing the same change in Incremental DOM (there is a slight hit), so I want to try to figure out why that is. |
For now, core's version are If you specify a
Yep. The buffer versions would be like
It would do what people expect for the most part, which is look up from a mapping to see if it should set a property or an attribute and maybe set |
So an initial stab at the implementation looks like this commit There are still a few open questions that need to be figured out. Probably some more that I am missing.
|
|
Of course, why am I not shocked.
Yeah, this would be for formatting functions for attribute values. Not sure if this is useful though.
One case I can think of is if you wanted to have custom logic, say, to add event listeners. So you might want something like:
For number 4, from my testing
is strictly worse than
if you optimize for the bufferAttribute flow. That is, copying the variable arguments into an array, then calling the diff function. Maybe for the same reason that pushing one item at a time into an array is better? For number 5, I would like to just add |
Forgot to mention that this would be useful for adding listeners for |
We want to bundle Incremental DOM as the defacto rendering pipeline for SkateJS (merged in from Kickflip). Part of the API of Skate is to be able to exist and seamlessly function with multiple versions of itself on the same page. In the virtual DOM module, we configure Incremental DOM a certain way and don't want that to leak to any other library that may be sharing that version of Incremental DOM, for example if NPM were to dedupe it between two separate packages so that they consumed the same version.
The text was updated successfully, but these errors were encountered: