Permalink
Browse files

Fix for case of template tag parameters of the form a.b(), to skip auto

detect of whether the return value of the function is itself of type
function.
The change is better for perf, has slightly reduced code size, and ensures
 (for non idempotent functions) that the function will only be called once.
  • Loading branch information...
1 parent 63ceb18 commit 19f6ba388b332e8a6625e24d1bec3565b9cc75f4 @BorisMoore BorisMoore committed Sep 1, 2010
Showing with 4 additions and 8 deletions.
  1. +4 −8 jquery.tmpl.js
View
@@ -326,14 +326,10 @@
if ( target ) {
target = unescape( target );
args = args ? ("," + unescape( args ) + ")") : (parens ? ")" : "");
- if ( parens && target.indexOf(".") > -1 ) {
- // Support for target being things like a.toLowerCase();
- // In that case don't call with template item as 'this' pointer. Just evaluate...
- target += parens;
- args = "";
- }
- expr = args ? ("(" + target + ").call($item" + args) : target;
- exprAutoFnDetect = args ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
+ // Support for target being things like a.toLowerCase();
+ // In that case don't call with template item as 'this' pointer. Just evaluate...
+ expr = parens ? (target.indexOf(".") > -1 ? target + parens : ("(" + target + ").call($item" + args)) : target;
+ exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
} else {
expr = def["$1"] || "null";
}

0 comments on commit 19f6ba3

Please sign in to comment.