Skip to content

Commit

Permalink
Moved callability into safe_var, made all args safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
benblank authored and borgar committed Jul 21, 2010
1 parent 5e4c16f commit 837289d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions jquery.tmpl.js
Expand Up @@ -7,7 +7,7 @@
(function(jQuery){
// Override the DOM manipulation function
var oldManip = jQuery.fn.domManip,
safe_var = "(function(){try{return $1;}catch(err){if(err.name==='ReferenceError'||err.name==='TypeError'){return undefined;}throw err;}}.call(this))",
safe_var = "(function(){try{return $.isFunction($1)?($1).call(this):$1;}catch(err){if(err.name==='ReferenceError'||err.name==='TypeError'){return undefined;}throw err;}}.call(this))",
rx_oper = /((<<|>?>>|[&\*\+-\/\^\|])?=|\+\+|--|\{|\}|\[)/,
rx_keywd = /\b(break|(cas|els|continu|delet|whil)e|(ca|swi)tch|with|default|do|finally|try|for|var|function|return|if|new|throw|void)\b/;

Expand Down Expand Up @@ -80,7 +80,7 @@
tmplcmd: {
"each": {
_default: [ null, "$i" ],
prefix: "_.safe=$SAFE;(function(){var $first=true;jQuery.each(typeof _.safe==='function'?_.safe.call(this):_.safe,function($2){with(this){",
prefix: "(function(){var $first=true;jQuery.each($SAFE,function($2){with(this){",
suffix: "}$first=false});}).call(this);"
},
"if": {
Expand All @@ -104,14 +104,14 @@
suffix: "}.call(_.safe,_.safe))"
},
"include": {
prefix: "_.push(String($1) in $.templates?$.templates[$1].call(this,$,this):'');"
prefix: "_.safe=$SAFE;_.push(String(_.safe) in $.templates?$.templates[_.safe].call(this,$,this):'');"
},
"html": {
prefix: "_.safe=$SAFE;_.push(typeof _.safe==='function'?_.safe.call(this):_.safe);"
prefix: "_.push($SAFE);"
},
"=": {
_default: [ "this" ],
prefix: "_.safe=$SAFE;_.push($.encode(typeof _.safe==='function'?_.safe.call(this):_.safe));"
prefix: "_.push($.encode($SAFE));"
}
},

Expand Down

0 comments on commit 837289d

Please sign in to comment.