Skip to content
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

Adding condition to unmount only components that already not in the Document object. #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ export function picoapp (components = {}, initialState = {}, plugins = []) {
unmount () {
for (let i = cache.length - 1; i > -1; i--) {
const { unmount, node, subs } = cache[i]

unmount(node)
subs.map(u => u())
cache.splice(i, 1)
if (!cache[i].node.isConnected){
unmount(node)
subs.map(u => u())
cache.splice(i, 1)
}
}

evx.emit('unmount')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dist"
],
"scripts": {
"prepare": "npm run build",
"build": "microbundle build --external none",
"watch": "microbundle watch --compress false",
"postbuild": "npm run test",
Expand Down