File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,13 @@ export default (config = {}) => {
172172 if ( typeof $elements === `undefined` || value === null ) return ;
173173
174174 $elements . forEach ( ( $element ) => {
175- if ( hasCustomValue ( $element ) ) return ;
175+ if ( hasCustomValue ( $element ) ) {
176+ const attr = propertyToGet ( $element ) ;
177+
178+ $element . setAttribute ( attr , value ) ;
179+
180+ return ;
181+ }
176182
177183 if ( $element . tagName === `INPUT` ) {
178184 let checked = value !== `undefined` && value === `` ;
Original file line number Diff line number Diff line change @@ -651,4 +651,25 @@ describe(`twoWayDataBinding`, () => {
651651
652652 expect ( proxy . country ) . toEqual ( `ES` ) ;
653653 } ) ;
654+
655+ it ( `Update element via proxy with custom value attribute [data-twowayvalue]` , ( ) => {
656+ const {
657+ container,
658+ bindName
659+ } = render (
660+ `<input data-model="country" data-bind="country" data-twowayvalue="ES" type="text" value="Spain (ES)" />` ,
661+ `data-bind`
662+ ) ;
663+
664+ const proxy = twoWayDataBinding ( {
665+ $context : container ,
666+ attributesCustomValue : [ `data-twowayvalue` ]
667+ } ) ;
668+ const $input = bindName ( `country` , `data-model` ) ;
669+
670+ proxy . country = `Germany (DE)` ;
671+
672+ expect ( $input . getAttribute ( `data-twowayvalue` ) ) . toEqual ( `Germany (DE)` ) ;
673+ expect ( $input . value ) . toEqual ( `Spain (ES)` ) ;
674+ } ) ;
654675} ) ;
You can’t perform that action at this time.
0 commit comments