mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 05:29:20 +03:00
KnockoutJS remove with($context) scope for faster access
This commit is contained in:
parent
932525566f
commit
c14bbab945
4 changed files with 11 additions and 19 deletions
|
|
@ -43,11 +43,6 @@ ko.bindingContext = class {
|
|||
}
|
||||
} else {
|
||||
self['$root'] = dataItem;
|
||||
|
||||
// Export 'ko' in the binding context so it will be available in bindings and templates
|
||||
// even if 'ko' isn't exported as a global, such as when using an AMD loader.
|
||||
// See https://github.com/SteveSanderson/knockout/issues/490
|
||||
self['ko'] = ko;
|
||||
}
|
||||
|
||||
self[contextSubscribable] = subscribable;
|
||||
|
|
|
|||
|
|
@ -35,12 +35,13 @@ ko.bindingProvider = new class
|
|||
// Build the source for a function that evaluates "expression"
|
||||
// For each scope variable, add an extra level of "with" nesting
|
||||
// Example result: with(sc1) { with(sc0) { return (expression) } }
|
||||
// Deprecated: with is no longer recommended
|
||||
var rewrittenBindings = ko.expressionRewriting.preProcessBindings(bindingsString),
|
||||
functionBody = "with($context){with($data||{}){return{" + rewrittenBindings + "}}}";
|
||||
bindingFunction = new Function("$context", "$element", functionBody);
|
||||
functionBody = "with($data){return{" + rewrittenBindings + "}}";
|
||||
bindingFunction = new Function("$root", "$parent", "$data", "$element", functionBody);
|
||||
bindingCache.set(cacheKey, bindingFunction);
|
||||
}
|
||||
return bindingFunction(bindingContext, node);
|
||||
return bindingFunction(bindingContext["$root"], bindingContext["$parent"], bindingContext["$data"] || {}, node);
|
||||
} catch (ex) {
|
||||
ex.message = "Unable to parse bindings.\nBindings value: " + bindingsString
|
||||
+ "\nMessage: " + ex.message;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue