Code Monkey home page Code Monkey logo

Comments (7)

7nik avatar 7nik commented on July 18, 2024 2

Hm, this

      return function ModalComponent(anchor, props2) {
	 return Component(
            anchor,
           {
               ...props,
               ...props2,
	  });
	}; 

doesn't cause double mounting.

If you do manual mounting, it's your responsibility to do manual unmounting. It just happened that at some points, Svelte sweeps away your manually mounted Popups. You can confirm this by adding an onDestroy logger to the Popup - it never logs in your REPL.

from svelte.

7nik avatar 7nik commented on July 18, 2024

duplicate of #11973

from svelte.

Neptunium1129 avatar Neptunium1129 commented on July 18, 2024

duplicate of #11973
I agree
But this problem is cause svelte mount.
#11973 is svelte fade

from svelte.

7nik avatar 7nik commented on July 18, 2024

Locally, I enabled legacy.componentApi and modified the code to

      return function ModalComponent(anchor, props_) {
        let options = props_ ? {
          target: anchor.nodeType == 8 ? anchor.parentNode : anchor,
          props: props_,
        } : anchor;

	return new Component({
        ...options,
          props: {
            ...props,
            ...options.props,
          },
        });

And it still does double mounting. Well, under the hood, it still uses mount().
Also, for some reason, with enabled legacy.componentApi it tries to mount to a comment node :D

from svelte.

Neptunium1129 avatar Neptunium1129 commented on July 18, 2024

thanks!!

from svelte.

dummdidumm avatar dummdidumm commented on July 18, 2024

As pointed out, adjusting the generated code will resolve the issue. The problem was that calling mount was wrong in this instance, because the component is rendered by the framework, not instantiated manually. What the bind method does is decorate the component. here's the fixed playground.

Therefore closing.

Note this is all deep into advanced Svelte territory, so it's totally understandable that it's not easy to grasp right away.

from svelte.

Neptunium1129 avatar Neptunium1129 commented on July 18, 2024

I just looked at the document, but it seems like something is very different. Thank you very much.

from svelte.

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.