mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 15:40:22 +00:00
compiler exposos both self and this function calling convention
This commit is contained in:
parent
c7d64f6d12
commit
ad18fe1442
3 changed files with 14 additions and 17 deletions
14
src/Scope.js
14
src/Scope.js
|
|
@ -46,16 +46,16 @@ function setter(instance, path, value){
|
|||
var compileCache = {};
|
||||
function expressionCompile(exp){
|
||||
if (isFunction(exp)) return exp;
|
||||
var expFn = compileCache[exp];
|
||||
if (!expFn) {
|
||||
var fn = compileCache[exp];
|
||||
if (!fn) {
|
||||
var parser = new Parser(exp);
|
||||
expFn = parser.statements();
|
||||
var fnSelf = parser.statements();
|
||||
parser.assertAllConsumed();
|
||||
compileCache[exp] = expFn;
|
||||
fn = compileCache[exp] = extend(
|
||||
function(){ return fnSelf(this);},
|
||||
{fnSelf: fnSelf});
|
||||
}
|
||||
return function(){
|
||||
return expFn(this);
|
||||
};
|
||||
return fn;
|
||||
}
|
||||
|
||||
function rethrow(e) { throw e; }
|
||||
|
|
|
|||
|
|
@ -296,10 +296,7 @@ var angularFunction = {
|
|||
if (isFunction(expression)){
|
||||
return expression;
|
||||
} else if (expression){
|
||||
var fn = expressionCompile(expression);
|
||||
return function($) {
|
||||
return fn.apply($);
|
||||
};
|
||||
return expressionCompile(expression).fnSelf;
|
||||
} else {
|
||||
return identity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,16 +155,16 @@ angularWidget("@ng-repeat", function(expression, element){
|
|||
this.$onEval(function(){
|
||||
var index = 0, childCount = children.length, childScope, lastElement = reference;
|
||||
foreach(this.$tryEval(rhs, reference), function(value, key){
|
||||
function assign(scope) {
|
||||
scope[valueIdent] = value;
|
||||
if (keyIdent) scope[keyIdent] = key;
|
||||
}
|
||||
if (index < childCount) {
|
||||
// reuse existing child
|
||||
assign(childScope = children[index]);
|
||||
childScope = children[index];
|
||||
childScope[valueIdent] = value;
|
||||
if (keyIdent) childScope[keyIdent] = key;
|
||||
} else {
|
||||
// grow children
|
||||
assign(childScope = template(element.clone(), createScope(currentScope)));
|
||||
childScope = template(element.clone(), createScope(currentScope));
|
||||
childScope[valueIdent] = value;
|
||||
if (keyIdent) childScope[keyIdent] = key;
|
||||
lastElement.after(childScope.$element);
|
||||
childScope.$index = index;
|
||||
childScope.$element.attr('ng-repeat-index', index);
|
||||
|
|
|
|||
Loading…
Reference in a new issue