Skip to content

Commit 68bde05

Browse files
committed
set property in v-attr
1 parent b4b55f1 commit 68bde05

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/directives/attr.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ module.exports = {
4444
} else {
4545
this.el.removeAttribute(attr)
4646
}
47+
if (attr in this.el) {
48+
this.el[attr] = value
49+
}
4750
}
4851

4952
}

test/unit/specs/directives/attr_spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ if (_.inBrowser) {
2626
expect(el.getAttribute('test')).toBe('0')
2727
})
2828

29+
it('should set property', function () {
30+
dir.el = document.createElement('input')
31+
dir.arg = 'value'
32+
dir.update('what')
33+
expect(dir.el.getAttribute('value')).toBe('what')
34+
expect(dir.el.value).toBe('what')
35+
})
36+
2937
it('xlink', function () {
3038
var xlinkNS = 'http://www.w3.org/1999/xlink'
3139
dir.arg = 'xlink:special'

0 commit comments

Comments
 (0)