Skip to content

Adds a widget destroy method #9097

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

saqimtiaz
Copy link
Member

@saqimtiaz saqimtiaz commented Jun 17, 2025

This PR adds a widget destroy method, and builds on the earlier work in #7468, which was reverted to allow more time for performance testing.

The key difference to that implementation is that a widget only removes its DOM nodes if an ancestor widget is not already going to remove an ancestor DOM node.

Apologies for the extended delay on this, it slipped through the cracks until I started reviewing all local branches that had not been pushed. It would be nice to get this into the upcoming v5.4.0 release that also allows for the possibility of limited backwards compatibility breaks.

To do:

Copy link

Confirmed: saqimtiaz has already signed the Contributor License Agreement (see contributing.md)

Copy link

github-actions bot commented Jun 17, 2025

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2528.0 KB
PR 2528.7 KB

Diff: ⬆️ Increase: +0.7 KB

Copy link

netlify bot commented Jun 17, 2025

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit 5357eb9
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/6851273bf4759f0008d1a789
😎 Deploy Preview https://deploy-preview-9097--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@saqimtiaz
Copy link
Member Author

@buggyj could you please check if this passes your tests? I tried to run them myself but it was unclear as to what a successful outcome looks like.

@pmario
Copy link
Member

pmario commented Jun 17, 2025

I did run https://destroytest.tiddlyhost.com/ with Saq's changes here and there seems to be some differences.

@buggyj -- I did test it with your destroytest at tiddlyhost according to your information in the test tiddlers. I think I did understand, what they should do. Using this branch with your plugin there is a different behaviour.

@saqimtiaz
Copy link
Member Author

I had another look at those tests and I am not certain they are universal enough to be relevant here.

For instance, they expect that the DOM node created by a widget persists until after the base class destroy() method has returned. However, the intention with the proposed code is that you do any additional tear down before calling the base class destroy() method.

@buggyj
Copy link
Contributor

buggyj commented Jun 18, 2025

@buggyj could you please check if this passes your tests? I tried to run them myself but it was unclear as to what a successful outcome looks like.

The test for v5.3.0 are here https://destroytests530prerelease.tiddlyhost.com/ , I will try them with this branch.

@buggyj
Copy link
Contributor

buggyj commented Jun 18, 2025

@buggyj could you please check if this passes your tests? I tried to run them myself but it was unclear as to what a successful outcome looks like.

@pmario @saqimtiaz I put the tests here https://destroytests537prerelease.tiddlyhost.com/ , they all pass.

These are only basic tests, I have not thought about DOM MutationObserver I believe that @linonetwo uses these...

@saqimtiaz
Copy link
Member Author

@buggyj thank you

@linonetwo when you get the chance please have a look.

@linonetwo
Copy link
Contributor

@saqimtiaz Great, please merge it soon.

@saqimtiaz saqimtiaz moved this from Backlog to Ready in Planning for v5.4.0 Jun 22, 2025
@saqimtiaz saqimtiaz marked this pull request as ready for review June 22, 2025 11:37
@linonetwo
Copy link
Contributor

linonetwo commented Jul 7, 2025

@saqimtiaz Could you add some test for this? Like a custom widget and test it is called. And dom tree only removed once. Or something related to performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

Successfully merging this pull request may close these issues.

4 participants