slimit
slimit copied to clipboard
SyntaxError: Unexpected token (CLASS, 'class')
When I try to parse a code containing the following :
_edit: function () {
if (this.options.can_edit) {
var self = this;
var $input = $('<input>', {class: 'o_input', type: 'text', value: this.$value.html()});
this.$value.html($input);
$input.focus();
// Event handlers
$input.click(function(ev) {
ev.stopPropagation(); // ignore clicks on the input
});
$input.blur(function(ev) {
self._save($(ev.target)); // save the state when leaving the input
});
$input.on('keydown', function (ev) {
ev.stopPropagation();
if (ev.which === $.ui.keyCode.ENTER) {
self._save($(ev.target)); // save on enter
} else if (ev.which === $.ui.keyCode.ESCAPE) {
self._render(); // leave on escape
}
});
}
},
it raise this error message :
SyntaxError: Unexpected token (CLASS, 'class') at 1:5220 between LexToken(LBRACE,'{',1,5219) and LexToken(COLON,':',1,5225)
it looks like a bug.
Yes, it's a known bug, see #52 and #59.
Basically any reserved keyword cannot be used as keys (or variables/attributes) through the slimit parser.