mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
perf(scope): re-enable statement cacheing
This commit is contained in:
parent
42062dab34
commit
13e7df68a6
3 changed files with 12 additions and 13 deletions
|
|
@ -433,7 +433,7 @@ Scope.prototype = {
|
|||
*/
|
||||
$eval: function(expr) {
|
||||
var fn = isString(expr)
|
||||
? parser(expr).statements()
|
||||
? expressionCompile(expr)
|
||||
: expr || noop;
|
||||
return fn(this);
|
||||
},
|
||||
|
|
@ -495,7 +495,7 @@ Scope.prototype = {
|
|||
|
||||
function compileToFn(exp, name) {
|
||||
var fn = isString(exp)
|
||||
? parser(exp).statements()
|
||||
? expressionCompile(exp)
|
||||
: exp;
|
||||
assertArgFn(fn, name);
|
||||
return fn;
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ angularDirective("ng:controller", function(expression){
|
|||
*/
|
||||
angularDirective("ng:bind", function(expression, element){
|
||||
element.addClass('ng-binding');
|
||||
var exprFn = parser(expression).statements();
|
||||
return function(element) {
|
||||
var lastValue = noop, lastError = noop;
|
||||
this.$watch(function(scope) {
|
||||
|
|
@ -215,7 +216,7 @@ angularDirective("ng:bind", function(expression, element){
|
|||
// TODO(misko): get rid of $element https://github.com/angular/angular.js/issues/348
|
||||
scope.$element = element;
|
||||
try {
|
||||
value = scope.$eval(expression);
|
||||
value = exprFn(scope);
|
||||
} catch (e) {
|
||||
scope.$service('$exceptionHandler')(e);
|
||||
error = formatError(e);
|
||||
|
|
|
|||
|
|
@ -526,23 +526,21 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn, textBox) {
|
|||
var scope = this,
|
||||
model = modelAccessor(scope, element),
|
||||
view = viewAccessor(scope, element),
|
||||
action = element.attr('ng:change') || noop,
|
||||
ngChange = element.attr('ng:change') || noop,
|
||||
lastValue;
|
||||
if (model) {
|
||||
initFn.call(scope, model, view, element);
|
||||
scope.$eval(element.attr('ng:init') || noop);
|
||||
element.bind(events, function(event){
|
||||
function handler(){
|
||||
scope.$apply(function() {
|
||||
var value = view.get();
|
||||
if (!textBox || value != lastValue) {
|
||||
model.set(value);
|
||||
lastValue = model.get();
|
||||
scope.$eval(action);
|
||||
}
|
||||
});
|
||||
var value = view.get();
|
||||
if (!textBox || value != lastValue) {
|
||||
model.set(value);
|
||||
lastValue = model.get();
|
||||
scope.$eval(ngChange);
|
||||
}
|
||||
}
|
||||
event.type == 'keydown' ? $defer(handler) : handler();
|
||||
event.type == 'keydown' ? $defer(handler) : scope.$apply(handler);
|
||||
});
|
||||
scope.$watch(model.get, function(scope, value) {
|
||||
if (!equals(lastValue, value)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue