Skip to content

Commit 72f2102

Browse files
committed
fix: Detect boolean attributes and expand them if value is empty (nativescript-vue#171)
1 parent 0afdc7a commit 72f2102

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

platform/nativescript/renderer/ViewNode.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,20 @@ export default class ViewNode {
9696
try {
9797
if (XML_ATTRIBUTES.indexOf(key) !== -1) {
9898
this.nativeView._applyXmlAttribute(key, value)
99-
} else if (isAndroid && key.startsWith('android:')) {
100-
set(this.nativeView, key.replace('android:', ''), value)
101-
} else if (isIOS && key.startsWith('ios:')) {
102-
set(this.nativeView, key.replace('ios:', ''), value)
10399
} else {
104-
set(this.nativeView, key, value)
100+
// detect expandable attrs for boolean values
101+
// See https://vuejs.org/v2/guide/components-props.html#Passing-a-Boolean
102+
if (typeof this.nativeView[key] === 'boolean' && value === '') {
103+
value = true
104+
}
105+
106+
if (isAndroid && key.startsWith('android:')) {
107+
set(this.nativeView, key.replace('android:', ''), value)
108+
} else if (isIOS && key.startsWith('ios:')) {
109+
set(this.nativeView, key.replace('ios:', ''), value)
110+
} else {
111+
set(this.nativeView, key, value)
112+
}
105113
}
106114
} catch (e) {
107115
// ignore

0 commit comments

Comments
 (0)