Skip to content

Commit

Permalink
Use charAt rather than string index
Browse files Browse the repository at this point in the history
Older versions of IE do not support [] access to string contents so charAt must be used.

Fixes #677
  • Loading branch information
kpdecker committed Dec 23, 2013
1 parent 7f0ded4 commit 3daef9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/handlebars/compiler/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ var AST = {
this.hash = hash;
this.strip = strip;

var escapeFlag = open[3] || open[2];
// Must use charAt to support IE pre-10
var escapeFlag = open.charAt(3) || open.charAt(2);
this.escaped = escapeFlag !== '{' && escapeFlag !== '&';

var id = this.id = rawParams[0];
Expand Down
4 changes: 2 additions & 2 deletions src/handlebars.yy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

function stripFlags(open, close) {
return {
left: open[2] === '~',
right: close[0] === '~' || close[1] === '~'
left: open.charAt(2) === '~',
right: close.charAt(0) === '~' || close.charAt(1) === '~'
};
}

Expand Down

0 comments on commit 3daef9d

Please sign in to comment.