Skip to content

Commit b00dbca

Browse files
committed
Merge pull request vuejs#2185 from rhyzx/boolean-attributes
Boolean attributes
2 parents e9fcaa9 + 1d4ea8e commit b00dbca

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/directives/public/bind.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ export default {
132132
}
133133
setClass(el, value)
134134
} else if (xlinkRE.test(attr)) {
135-
el.setAttributeNS(xlinkNS, attr, value)
135+
el.setAttributeNS(xlinkNS, attr, value === true ? '' : value)
136136
} else {
137-
el.setAttribute(attr, value)
137+
el.setAttribute(attr, value === true ? '' : value)
138138
}
139139
} else {
140140
el.removeAttribute(attr)

test/unit/specs/directives/public/bind_spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ describe('v-bind', function () {
2424
expect(el.hasAttribute('test')).toBe(false)
2525
dir.update(false)
2626
expect(el.hasAttribute('test')).toBe(false)
27+
dir.update(true)
28+
expect(el.getAttribute('test')).toBe('')
2729
dir.update(0)
2830
expect(el.getAttribute('test')).toBe('0')
2931
})

0 commit comments

Comments
 (0)