Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on Node.js global object #1776

Merged
merged 1 commit into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
env: {
// Handlebars should run natively in the browser
node: false
}
};
4 changes: 2 additions & 2 deletions lib/handlebars/compiler/code-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ let SourceNode;
try {
/* istanbul ignore next */
if (typeof define !== 'function' || !define.amd) {
// We don't support this in AMD environments. For these environments, we asusme that
// We don't support this in AMD environments. For these environments, we assume that
// they are running on the browser and thus have no need for the source-map library.
let SourceMap = require('source-map');
let SourceMap = require('source-map'); // eslint-disable-line no-undef
SourceNode = SourceMap.SourceNode;
}
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions lib/handlebars/helpers/each.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export default function(instance) {
execIteration(i, i, i === context.length - 1);
}
}
} else if (global.Symbol && context[global.Symbol.iterator]) {
} else if (typeof Symbol === 'function' && context[Symbol.iterator]) {
const newContext = [];
const iterator = context[global.Symbol.iterator]();
const iterator = context[Symbol.iterator]();
for (let it = iterator.next(); !it.done; it = iterator.next()) {
newContext.push(it.value);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars/no-conflict.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function(Handlebars) {
/* istanbul ignore next */
let root = typeof global !== 'undefined' ? global : window,
let root = typeof global !== 'undefined' ? global : window, // eslint-disable-line no-undef
$Handlebars = root.Handlebars;
/* istanbul ignore next */
Handlebars.noConflict = function() {
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// USAGE:
// var handlebars = require('handlebars');
/* eslint-env node */
/* eslint-disable no-var */

// var local = handlebars.create();
Expand Down
1 change: 1 addition & 0 deletions lib/precompiler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
/* eslint-disable no-console */
import Async from 'neo-async';
import fs from 'fs';
Expand Down