Comments (7)
Yes, a regular reference will probably suffice. The good thing is that the compiler will tell us whether it's needed or not π
from percy.
Ahhh thanks for raising this.. I'd actually forgotten about this.
It's not mandatory, IIRC I had a lifetime issue and just did it this way to make it work. This was either before web_sys
existed or shortly after it was published..
Regardless it's not desired.. so if you want to take a stab at making it mutable I'd be happy to answer any questions along the way!
from percy.
Will probably give this a try next week!
from percy.
Sweet! Again, I really donβt remember the problem, it might not have even been lifetimes and instead have been multiple mutable references or something.
Regardless Iβm sure it was just poor form on my end and not a fundamental issue.
Although does this suggest that we might want a reference instead of a miracle reference ...?
from percy.
Hm, it's not that easy, because you are inserting the element into the nodes_to_patch
hashmap.
This should be doable with only references by rewriting the patching algorithm. I'll try to take a quick look when I find time, but don't know yet if that'll be today or not.
from percy.
Ok, changing it to references using the same recursive algorithm is a bit tricky because of the lifetimes involved.
Since the Element
is clonable we could simply clone it (see master...dbrgn:patch-ownership), but I'm not sure if that's worth the improved API because this way the element always gets cloned, while it might not need to be cloned if the user doesn't need the reference to the element anymore after patching.
Another option would be to accept the element by value, to create an Rc from it, and to pass that Rc to the find_nodes
function. Then in the end we could return the original element by value. But every Rc causes an allocation and I'm not even sure how to unwrap the Rc to recover the original value π So I think it might be best to stick to the current approach unless someone figures out lifetime annotations to be able to stick to references only.
TLDR: The user can clone the element before passing it to the patch
function.
from percy.
SWEET thanks for looking into this!
Ah so it was a lifetime issue - I vaguely remember haha ..
Sweet this sounds great for now ππΏ
from percy.
Related Issues (20)
- How alive is this project? HOT 3
- Use request_animation_frame from rust instead of Global Js call for update view HOT 3
- Free hosting? HOT 5
- Sub-routes not working? HOT 1
- Bash files in examples to rust-script? HOT 5
- Curly braces for value interpolation HOT 1
- Implement Performance Metrics HOT 2
- Implement a Formatting Tool HOT 2
- Consider Pure JS Transpilation HOT 2
- FYI: branding/naming clash HOT 1
- Crate renames HOT 1
- Docs: Broken CSS HOT 1
- Broken tests in html-macro 0.7.0 and 0.7.1 HOT 4
- Building nojs-first applications (and some thoughts about an isomorphic data layer) HOT 1
- Free Hosting for Demos HOT 1
- Allow Support for multiple parameters in `JSX` syntax HOT 4
- Spaces removed when isomorphic app is hydrated HOT 3
- File referred to in documentation doesn't exist
- Fix parenthesized blocks in html macro
- Panic happened in /allocator/free_list.rs that `new_page == 0` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from percy.