From 47394f14879147de4a402f26f3bfaf0a0756e9f4 Mon Sep 17 00:00:00 2001 From: beyaz Date: Sat, 13 Jan 2024 16:08:50 +0300 Subject: [PATCH] . --- .../react-with-dotnet/react-with-dotnet.jsx | 36 +++++++++++++------ .../react-with-dotnet/react-with-dotnet.jsx | 36 +++++++++++++------ 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/ReactWithDotNet.WebSite/wwwroot/react-with-dotnet/react-with-dotnet.jsx b/ReactWithDotNet.WebSite/wwwroot/react-with-dotnet/react-with-dotnet.jsx index 49e432d1..cff8b4cb 100644 --- a/ReactWithDotNet.WebSite/wwwroot/react-with-dotnet/react-with-dotnet.jsx +++ b/ReactWithDotNet.WebSite/wwwroot/react-with-dotnet/react-with-dotnet.jsx @@ -2666,6 +2666,25 @@ function CreateNewDeveloperError(message) const DynamicStyles = []; var ReactWithDotNetDynamicCssElement = null; +/** + * + * @param {String} cssSelector + * @returns {Number} ComponentUniqueIdentifier + */ +function GetComponentUniqueIdentifierFromCssSelector(cssSelector) +{ + let startIndex = cssSelector.indexOf('._rwd_'); + let endIndex = cssSelector.indexOf('_', startIndex + 6); + + const componentUniqueIdentifier = parseInt(cssSelector.substring(startIndex + 6, endIndex)); + if (isNaN(componentUniqueIdentifier)) + { + throw CreateNewDeveloperError('componentUniqueIdentifier cannot calculated from ' + cssSelector); + } + + return componentUniqueIdentifier; +} + function ProcessDynamicCssClasses(dynamicStyles) { if (dynamicStyles == null || dynamicStyles.length === 0) @@ -2703,17 +2722,12 @@ function ProcessDynamicCssClasses(dynamicStyles) if (shouldInsert) { hasChange = true; - - let startIndex = cssSelector.indexOf('._rwd_'); - let endIndex = cssSelector.indexOf('_', startIndex + 6); - - const componentUniqueIdentifier = parseInt(cssSelector.substring(startIndex + 6, endIndex)); - if (isNaN(componentUniqueIdentifier)) - { - throw CreateNewDeveloperError('componentUniqueIdentifier cannot calculated from ' + cssSelector); - } - - DynamicStyles.push({cssSelector: cssSelector, cssBody: cssBody, componentUniqueIdentifier: componentUniqueIdentifier}); + + DynamicStyles.push({ + cssSelector: cssSelector, + cssBody: cssBody, + componentUniqueIdentifier: GetComponentUniqueIdentifierFromCssSelector(cssSelector) + }); } } } diff --git a/ReactWithDotNet/JsClientEngine/react-with-dotnet/react-with-dotnet.jsx b/ReactWithDotNet/JsClientEngine/react-with-dotnet/react-with-dotnet.jsx index 49e432d1..cff8b4cb 100644 --- a/ReactWithDotNet/JsClientEngine/react-with-dotnet/react-with-dotnet.jsx +++ b/ReactWithDotNet/JsClientEngine/react-with-dotnet/react-with-dotnet.jsx @@ -2666,6 +2666,25 @@ function CreateNewDeveloperError(message) const DynamicStyles = []; var ReactWithDotNetDynamicCssElement = null; +/** + * + * @param {String} cssSelector + * @returns {Number} ComponentUniqueIdentifier + */ +function GetComponentUniqueIdentifierFromCssSelector(cssSelector) +{ + let startIndex = cssSelector.indexOf('._rwd_'); + let endIndex = cssSelector.indexOf('_', startIndex + 6); + + const componentUniqueIdentifier = parseInt(cssSelector.substring(startIndex + 6, endIndex)); + if (isNaN(componentUniqueIdentifier)) + { + throw CreateNewDeveloperError('componentUniqueIdentifier cannot calculated from ' + cssSelector); + } + + return componentUniqueIdentifier; +} + function ProcessDynamicCssClasses(dynamicStyles) { if (dynamicStyles == null || dynamicStyles.length === 0) @@ -2703,17 +2722,12 @@ function ProcessDynamicCssClasses(dynamicStyles) if (shouldInsert) { hasChange = true; - - let startIndex = cssSelector.indexOf('._rwd_'); - let endIndex = cssSelector.indexOf('_', startIndex + 6); - - const componentUniqueIdentifier = parseInt(cssSelector.substring(startIndex + 6, endIndex)); - if (isNaN(componentUniqueIdentifier)) - { - throw CreateNewDeveloperError('componentUniqueIdentifier cannot calculated from ' + cssSelector); - } - - DynamicStyles.push({cssSelector: cssSelector, cssBody: cssBody, componentUniqueIdentifier: componentUniqueIdentifier}); + + DynamicStyles.push({ + cssSelector: cssSelector, + cssBody: cssBody, + componentUniqueIdentifier: GetComponentUniqueIdentifierFromCssSelector(cssSelector) + }); } } }