File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -493,16 +493,26 @@ Parser.prototype.generate = function(ctx) {
493493} ;
494494
495495Parser . prototype . generateEncode = function ( ctx ) {
496- // Transform with the possibly provided encoder before encoding
497496 var varName = ctx . generateVariable ( this . varName ) ;
497+ var savVarName = ctx . generateTmpVariable ( ) ;
498+
499+ // Transform with the possibly provided encoder before encoding
498500 if ( this . options . encoder ) {
501+ // Save varName before applying encoder
502+ ctx . pushCode ( "var {0} = {1};" , savVarName , varName ) ;
499503 this . generateEncoder ( ctx , varName , this . options . encoder ) ;
500504 }
501505
502506 if ( this . type ) {
503507 this [ "generate_encode" + this . type ] ( ctx ) ;
504508 }
505509
510+ if ( this . options . encoder ) {
511+ // Restore varName after encoder transformation so that next parsers will
512+ // have access to original field value (but not nested ones)
513+ ctx . pushCode ( "{0} = {1};" , varName , savVarName ) ;
514+ }
515+
506516 return this . generateEncodeNext ( ctx ) ;
507517} ;
508518
You can’t perform that action at this time.
0 commit comments