@@ -1618,6 +1618,7 @@ ko.bindingProvider = new class
1618
1618
try {
1619
1619
let cacheKey = bindingsString ,
1620
1620
bindingFunction = bindingCache . get ( cacheKey ) ;
1621
+ /*
1621
1622
if (!bindingFunction) {
1622
1623
// Build the source for a function that evaluates "expression"
1623
1624
// For each scope variable, add an extra level of "with" nesting
@@ -1631,6 +1632,23 @@ ko.bindingProvider = new class
1631
1632
return bindingFunction(bindingContext,
1632
1633
bindingContext["$root"], bindingContext["$parent"], bindingContext["$data"] || {}, node
1633
1634
);
1635
+ */
1636
+ if ( ! bindingFunction ) {
1637
+ // Build the source for a function that evaluates "expression"
1638
+ // Use one "with" that has one secure scope handling Proxy
1639
+ // Deprecated: with is no longer recommended
1640
+ var rewrittenBindings = ko . expressionRewriting . preProcessBindings ( bindingsString ) ,
1641
+ functionBody = "$context = new Proxy(\
1642
+ $context,\
1643
+ {\
1644
+ has: () => true,\
1645
+ get: (target, key) => target[key] || target['$data'][key]\
1646
+ }\
1647
+ );with($context){return{" + rewrittenBindings + "}}" ;
1648
+ bindingFunction = new Function ( "$context" , functionBody ) ;
1649
+ bindingCache . set ( cacheKey , bindingFunction ) ;
1650
+ }
1651
+ return bindingFunction ( bindingContext ) ;
1634
1652
} catch ( ex ) {
1635
1653
ex . message = "Unable to parse bindings.\nBindings value: " + bindingsString
1636
1654
+ "\nMessage: " + ex . message ;
0 commit comments