Add missing reserved words so compiler knows to use array syntax:
* await * null * true * false IE 8 was failing to compile Handlebars-generated source code because it had helpers.null. I came up with this list by diffing https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords against the ones Handlebars already had. I added two corresponding tests for nameLookup.
This commit is contained in:
@@ -1025,7 +1025,8 @@ var reservedWords = (
|
||||
" class float package throws" +
|
||||
" const goto private transient" +
|
||||
" debugger implements protected volatile" +
|
||||
" double import public let yield"
|
||||
" double import public let yield await" +
|
||||
" null true false"
|
||||
).split(" ");
|
||||
|
||||
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
|
||||
|
||||
@@ -19,6 +19,12 @@ describe('javascript-compiler api', function() {
|
||||
};
|
||||
shouldCompileTo("{{foo}}", { bar_foo: "food" }, "food");
|
||||
});
|
||||
|
||||
// Tests nameLookup dot vs. bracket behavior. Bracket is required in certain cases
|
||||
// to avoid errors in older browsers.
|
||||
it('should handle reserved words', function() {
|
||||
shouldCompileTo("{{foo}} {{~null~}}", { foo: "food" }, "food");
|
||||
});
|
||||
});
|
||||
describe('#compilerInfo', function() {
|
||||
var $superCheck, $superInfo;
|
||||
|
||||
Reference in New Issue
Block a user