Giter Club home page Giter Club logo

Comments (12)

Raynos avatar Raynos commented on July 2, 2024

I need to somehow add an escape clause in main-loop then update mercury to wire in the correct escape clause, i.e. mutation is allowed in synchronous DOM events from dom-delegator.

from mercury.

kumavis avatar kumavis commented on July 2, 2024

wow thats an interesting edge-case!

from mercury.

kumavis avatar kumavis commented on July 2, 2024

@neonstalwart so the problem is that it is firing an event registered for an element that no longer in the dom? If so, perhaps we could just do a check for the element being in the DOM before calling the handler
Is there a case where we'd want it to fire even though the element has been removed?

from mercury.

neonstalwart avatar neonstalwart commented on July 2, 2024

@kumavis the problem removing nodes is not the main point - that is something I've been able to mostly address in virtual-dom. the real problem you should give your attention to is that blur events fire synchronously and if you do something to shift focus during a render then your blur handler will be fired in the middle of a render. if your blur handler mutates state then an error will be thrown because you are not allowed to mutate state during a render. this is something which is actually quite common once you do anything that uses a blur handler.

from mercury.

kumavis avatar kumavis commented on July 2, 2024

gotcha!
i remember the ember core folks talking about having to invalidate renders.
i wonder if we could somehow fire blur handlers for to-be-removed elements after virtual render but before dom render...

so we would virtual render twice (or more) and dom render once

from mercury.

neonstalwart avatar neonstalwart commented on July 2, 2024

after talking more with @kumavis in irc, we came to realize that maybe we could ignore state mutations during the patch phase. the error is really for the purpose of stopping people mutating state during render but this mutation is happening during patch. @Raynos what do you think about changing main-loop so that InvalidUpdateInRender does not throw during the patch phase?

from mercury.

Raynos avatar Raynos commented on July 2, 2024

@neonstalwart

We want to gaurd the patch phase to stop people doing naughty things in hooks and widgets.

Can we update dom-delegator to force blur into a next-tick ? Would that fix the problem ?

from mercury.

neonstalwart avatar neonstalwart commented on July 2, 2024

i don't think we can delay the event - then you can't prevent a blur. also, it's not uncommon for blur and focus logic to work together. if you try to delay the events you'll probably introduce a whole slew of new problems worse than this one.

from mercury.

kumavis avatar kumavis commented on July 2, 2024

I would accept allowing state change during a patch as the lesser of evils

from mercury.

Raynos avatar Raynos commented on July 2, 2024

@kumavis @neonstalwart seems reasonable. However let's gaurd both tree creation & diff because of how thunks do lazy tree creation.

from mercury.

kumavis avatar kumavis commented on July 2, 2024

pending Raynos/main-loop#15
and updating main-loop dep here

from mercury.

Raynos avatar Raynos commented on July 2, 2024

Fixed in latest mercury.

from mercury.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.