From e3ecf292544fc07ab158f46334c61634caf1657e Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 10 Oct 2024 10:21:54 -0700 Subject: [PATCH] simplify special attribute checking logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit avoid special cases in the special case handling code 🙄 --- reflex/constants/compiler.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/reflex/constants/compiler.py b/reflex/constants/compiler.py index 238d16da0..557a92092 100644 --- a/reflex/constants/compiler.py +++ b/reflex/constants/compiler.py @@ -169,8 +169,10 @@ class SpecialAttributes(enum.Enum): to a style prop. """ - DATA = "data" - ARIA = "aria" + DATA_UNDERSCORE = "data_" + DATA_DASH = "data-" + ARIA_UNDERSCORE = "aria_" + ARIA_DASH = "aria-" @classmethod def is_special(cls, attr: str) -> bool: @@ -182,7 +184,4 @@ class SpecialAttributes(enum.Enum): Returns: True if the attribute is special. """ - for value in cls: - if attr.startswith(f"{value.value}-") or attr.startswith(f"{value.value}_"): - return True - return False + return any(attr.startswith(value.value) for value in cls)