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
1212// these attributes should also set their corresponding properties
1313// because they only affect the initial state of the element
1414const 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 ) $ /
1518
1619// these attributes should set a hidden property for
1720// binding v-model to object values
@@ -126,7 +129,9 @@ export default {
126129 return
127130 }
128131 // 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 ) {
130135 if ( attr === 'class' ) {
131136 // handle edge case #1960:
132137 // 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 () {
8080 dir . update ( '0 0 1500 1000' )
8181 expect ( dir . el . getAttribute ( 'viewBox' ) ) . toBe ( '0 0 1500 1000' )
8282 } )
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+ } )
8393} )
You can’t perform that action at this time.
0 commit comments