Skip to content

Commit e252544

Browse files
committed
fix: fix view already has a parent bug
fixes nativescript-vue#59, closes nativescript-vue#78
1 parent 00de33f commit e252544

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"rollup-plugin-resolve-aliases": "^0.2.0",
7070
"rollup-watch": "^3.2.2",
7171
"semver": "^5.4.1",
72-
"tns-core-modules": "^3.3.0",
72+
"tns-core-modules": "^3.4.0",
7373
"util-inspect": "^0.1.8",
7474
"vue": "^2.5.13"
7575
},
@@ -83,8 +83,7 @@
8383
"!**/node_modules/**"
8484
],
8585
"moduleDirectories": [
86-
"node_modules",
87-
"<rootDir>/node_modules/tns-core-modules"
86+
"node_modules"
8887
],
8988
"modulePathIgnorePatterns": [
9089
"<rootDir>/samples"

platform/nativescript/framework.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
global.process = global.process || {}
44
global.process.env = global.process.env || {}
55

6+
import { VUE_VM_REF } from './runtime'
67
import inspect from 'util-inspect'
8+
import { topmost } from 'ui/frame'
9+
import application from 'application'
710
import Vue from './runtime/index'
811
import ModalPlugin from './plugins/modal-plugin'
912
import NavigatorPlugin from './plugins/navigator-plugin'
@@ -30,4 +33,23 @@ console.keys = function(object) {
3033
console.log(Object.keys(object))
3134
}
3235

36+
// this fixes the issue of resuming the application
37+
// however this might not be the desired functionality
38+
// Todo: figure out if there is a better way to fix application resume.
39+
application.on(application.exitEvent, () => {
40+
const frame = topmost()
41+
if (frame) {
42+
console.log(frame)
43+
frame.eachChildView(child => {
44+
console.log('found child')
45+
const vm = child[VUE_VM_REF]
46+
47+
if (vm) {
48+
vm.$destroy()
49+
}
50+
frame._removeView(child)
51+
})
52+
}
53+
})
54+
3355
export default Vue

platform/nativescript/plugins/navigator-plugin.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ export default {
2121
const navigate = frame ? frame.navigate : start
2222

2323
if (isPage(component)) {
24-
return navigate({
25-
create() {
26-
return component
27-
}
28-
})
24+
return navigate(
25+
Object.assign(options, {
26+
create() {
27+
return component
28+
}
29+
})
30+
)
2931
}
3032

3133
const placeholder = Vue.$document.createComment('placeholder')

platform/nativescript/runtime/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const mount = function(el, hydrating) {
5353
page.content = self.$el.nativeView
5454
}
5555

56+
page[VUE_VM_REF] = self
57+
5658
return page
5759
}
5860
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy