Skip to content

Commit

Permalink
Fixed setTextContent in cases where a placeholder child element is used.
Browse files Browse the repository at this point in the history
Updated example app to test even more features.
  • Loading branch information
rigor789 committed Apr 22, 2017
1 parent 4fe358c commit 8da45a1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
12 changes: 10 additions & 2 deletions nativescript-vue/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nativescript-vue/dist/index.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion nativescript-vue/platform/nativescript/renderer/view-node.js
Expand Up @@ -45,6 +45,14 @@ export default class ViewNode {
}
}

setText(text) {
if (this.type === 'detached-text') {
this.parent.setText(text)
} else {
this.setAttr('text', text)
}
}

addEvent(evt, handler) {
this.view.on(evt, handler)
}
Expand Down Expand Up @@ -93,7 +101,7 @@ export default class ViewNode {
}
} else if (isTextView(this.view)) {
child.view.parent = this.view
this.setAttr('text', child.view.text)
this.setText(child.view.text)
} else {
child.parent = null
console.log(`Cant append child to ${this.type}`)
Expand Down
2 changes: 1 addition & 1 deletion nativescript-vue/platform/nativescript/runtime/node-ops.js
Expand Up @@ -75,7 +75,7 @@ export function tagName(elementNode) {
export function setTextContent(node, text) {
console.log(`{NSVue} -> SetTextContent(${node}, ${text})`)

node.setAttr('text', text)
node.setText(text)
}

export function setAttribute(nodeElement, key, val) {
Expand Down
Binary file added vue-sample/app/images/vue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions vue-sample/app/main-page.js
Expand Up @@ -23,15 +23,22 @@ function onReady(page) {
<button @tap="textRed = !textRed" style="color: white; background-color: darkcyan;">TAP HERE</button>
<label :style="{color: textRed ? 'red' : 'blue'}" style="text-align: center; margin-top: 20; font-size: 40" :text="showTrick ? 'Poof!' : 'Wait for it!'"></label>
<button @tap="showTrick = !showTrick">Tap to see a trick!</button>
<image v-if="showTrick" src="~/images/apple.jpg"></image>
<image v-if="showTrick" style="height: 200;" :src="imgSrc"></image>
<scroll-view orientation="horizontal" style="height: 100">
<stack-layout orientation="horizontal">
<image v-for="i in 10" :src="i%2 ? '~/images/apple.jpg' : '~/images/vue.png'" @tap="imgSrc = i%2 ? '~/images/apple.jpg' : '~/images/vue.png'"></image>
</stack-layout>
</scroll-view>
</stack-layout>
</scroll-view>
`,

data: {
textRed: false,
showTrick: false
showTrick: false,
imgSrc: '~/images/apple.jpg'
},

methods: {
Expand Down

0 comments on commit 8da45a1

Please sign in to comment.