Skip to content

Commit e252544

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

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

Diff for: package.json

+2-3
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"

Diff for: platform/nativescript/framework.js

+22
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

Diff for: platform/nativescript/plugins/navigator-plugin.js

+7-5
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')

Diff for: platform/nativescript/runtime/index.js

+2
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)