Skip to content

Commit

Permalink
Upgrade to ECMAScript 2020
Browse files Browse the repository at this point in the history
This is needed in order to use `globalThis`, see #1894.
It also made it possible to remove some old polyfills and fallbacks.
  • Loading branch information
jaylinski committed Oct 29, 2022
1 parent da41887 commit f6ff3bf
Show file tree
Hide file tree
Showing 21 changed files with 1,191 additions and 1,618 deletions.
10 changes: 4 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ module.exports = {
},
env: {
node: true,
es6: true
es2020: true
},
parserOptions: {
sourceType: 'module'
},
rules: {
'no-console': 'warn',
Expand Down Expand Up @@ -57,10 +60,5 @@ module.exports = {
// ECMAScript 6 //
//--------------//
'no-var': 'error'
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 6,
ecmaFeatures: {}
}
};
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ There are a few Mustache behaviors that Handlebars does not implement.
Supported Environments
----------------------

Handlebars has been designed to work in any ECMAScript 7 (2016) environment. This includes
Handlebars has been designed to work in any ECMAScript 2020 environment. This includes

- Node.js
- Chrome
Expand Down
1 change: 1 addition & 0 deletions lib/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
module.exports = {
env: {
// Handlebars should run natively in the browser
Expand Down
3 changes: 2 additions & 1 deletion lib/handlebars/compiler/javascript-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ JavaScriptCompiler.prototype = {
this.decorators.push('return fn;');

if (asObject) {
// eslint-disable-next-line no-new-func
this.decorators = Function.apply(this, [
'fn',
'props',
Expand Down Expand Up @@ -260,7 +261,7 @@ JavaScriptCompiler.prototype = {
if (asObject) {
params.push(source);

return Function.apply(this, params);
return Function.apply(this, params); // eslint-disable-line no-new-func
} else {
return this.source.wrap([
'function(',
Expand Down
17 changes: 2 additions & 15 deletions lib/handlebars/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,10 @@ export function extend(obj /* , ...source */) {
export let toString = Object.prototype.toString;

// Sourced from lodash
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
/* eslint-disable func-style */
let isFunction = function(value) {
// https://github.com/lodash/lodash/blob/4.17.21/LICENSE
export function isFunction(value) {
return typeof value === 'function';
};
// fallback for older versions of Chrome and Safari
/* istanbul ignore next */
if (isFunction(/x/)) {
isFunction = function(value) {
return (
typeof value === 'function' &&
toString.call(value) === '[object Function]'
);
};
}
export { isFunction };
/* eslint-enable func-style */

/* istanbul ignore next */
export const isArray =
Expand Down

0 comments on commit f6ff3bf

Please sign in to comment.