File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -862,18 +862,22 @@ defaultMethods.var.compile = function (data, buildState) {
862862 const pieces = splitPath ( key )
863863 const [ top ] = pieces
864864 buildState . varTop . add ( top )
865+
866+ if ( ! buildState . engine . allowFunctions ) buildState . methods . preventFunctions = a => typeof a === 'function' ? null : a
867+ else buildState . methods . preventFunctions = a => a
868+
865869 // support older versions of node
866870 if ( ! chainingSupported ) {
867- return `(((a,b) => (typeof a === 'undefined' || a === null) ? b : a)(${ pieces . reduce (
871+ return `(methods.preventFunctions( ((a,b) => (typeof a === 'undefined' || a === null) ? b : a)(${ pieces . reduce (
868872 ( text , i ) => {
869873 return `(${ text } ||0)[${ JSON . stringify ( i ) } ]`
870874 } ,
871875 '(context||0)'
872- ) } , ${ buildString ( defaultValue , buildState ) } ))`
876+ ) } , ${ buildString ( defaultValue , buildState ) } ))) `
873877 }
874- return `(context${ pieces
878+ return `(methods.preventFunctions( context${ pieces
875879 . map ( ( i ) => `?.[${ JSON . stringify ( i ) } ]` )
876- . join ( '' ) } ?? ${ buildString ( defaultValue , buildState ) } )`
880+ . join ( '' ) } ?? ${ buildString ( defaultValue , buildState ) } )) `
877881 }
878882 buildState . useContext = true
879883 return false
You can’t perform that action at this time.
0 commit comments