From efc6568f775bdfea5ce72ccfcf8c36b00ab50845 Mon Sep 17 00:00:00 2001 From: websoftlab <98396369+websoftlab@users.noreply.github.com> Date: Mon, 19 Jun 2023 11:06:05 +0300 Subject: [PATCH] Fix for @global name validation --- packages/jss-plugin-global/src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/jss-plugin-global/src/index.js b/packages/jss-plugin-global/src/index.js index cc970022e..20829577b 100644 --- a/packages/jss-plugin-global/src/index.js +++ b/packages/jss-plugin-global/src/index.js @@ -136,11 +136,13 @@ export default function jssGlobal() { function onCreateRule(name, styles, options) { if (!name) return null - if (name === at) { + // The original name is used for validation as the system name can be `@global-X` which will throw error + const originName = options?.name || name; + if (originName === at) { return new GlobalContainerRule(name, styles, options) } - if (name[0] === '@' && name.substr(0, atPrefix.length) === atPrefix) { + if (originName[0] === '@' && originName.substr(0, atPrefix.length) === atPrefix) { return new GlobalPrefixedRule(name, styles, options) }