From 138af6ac0e5af01cdb36c1ea505457c8115df361 Mon Sep 17 00:00:00 2001 From: Jakob Linskeseder Date: Wed, 19 Oct 2022 21:46:23 +0200 Subject: [PATCH] Make library compatible with workers Pulled from 4.x branch, see #1894. --- lib/handlebars/no-conflict.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/handlebars/no-conflict.js b/lib/handlebars/no-conflict.js index 5a6db3e9a..bfd8a41bb 100644 --- a/lib/handlebars/no-conflict.js +++ b/lib/handlebars/no-conflict.js @@ -1,11 +1,10 @@ -export default function(Handlebars) { +export default function (Handlebars) { + let $Handlebars = globalThis.Handlebars; + /* istanbul ignore next */ - let root = typeof global !== 'undefined' ? global : window, // eslint-disable-line no-undef - $Handlebars = root.Handlebars; - /* istanbul ignore next */ - Handlebars.noConflict = function() { - if (root.Handlebars === Handlebars) { - root.Handlebars = $Handlebars; + Handlebars.noConflict = function () { + if (globalThis.Handlebars === Handlebars) { + globalThis.Handlebars = $Handlebars; } return Handlebars; };