File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ const disallowedInterpAttrRE = /^v-|^:|^@|^(?:is|transition|transition-mode|debo
12
12
// these attributes should also set their corresponding properties
13
13
// because they only affect the initial state of the element
14
14
const attrWithPropsRE = / ^ (?: v a l u e | c h e c k e d | s e l e c t e d | m u t e d ) $ /
15
+ // these attributes expect enumrated values of "true" or "false"
16
+ // but are not boolean attributes
17
+ const enumeratedAttrRE = / ^ (?: d r a g g a b l e | c o n t e n t e d i t a b l e | s p e l l c h e c k ) $ /
15
18
16
19
// these attributes should set a hidden property for
17
20
// binding v-model to object values
@@ -126,7 +129,9 @@ export default {
126
129
return
127
130
}
128
131
// update attribute
129
- if ( value != null && value !== false ) {
132
+ if ( enumeratedAttrRE . test ( attr ) ) {
133
+ el . setAttribute ( attr , value ? 'true' : 'false' )
134
+ } else if ( value != null && value !== false ) {
130
135
if ( attr === 'class' ) {
131
136
// handle edge case #1960:
132
137
// class interpolation should not overwrite Vue transition class
Original file line number Diff line number Diff line change @@ -80,4 +80,14 @@ describe('v-bind', function () {
80
80
dir . update ( '0 0 1500 1000' )
81
81
expect ( dir . el . getAttribute ( 'viewBox' ) ) . toBe ( '0 0 1500 1000' )
82
82
} )
83
+
84
+ it ( 'enumrated non-boolean attributes' , function ( ) {
85
+ [ 'draggable' , 'contenteditable' , 'spellcheck' ] . forEach ( function ( attr ) {
86
+ dir . arg = attr
87
+ dir . update ( true )
88
+ expect ( el . getAttribute ( attr ) ) . toBe ( 'true' )
89
+ dir . update ( false )
90
+ expect ( el . getAttribute ( attr ) ) . toBe ( 'false' )
91
+ } )
92
+ } )
83
93
} )
You can’t perform that action at this time.
0 commit comments