simplify special attribute checking logic

avoid special cases in the special case handling code 🙄
This commit is contained in:
Masen Furer 2024-10-10 10:21:54 -07:00
parent 593a0229fa
commit e3ecf29254
No known key found for this signature in database
GPG Key ID: B0008AD22B3B3A95

View File

@ -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)