From f05ee1552deda62ff90075dffd528dc888a77d5a Mon Sep 17 00:00:00 2001 From: anlyyao Date: Wed, 23 Oct 2024 15:25:36 +0800 Subject: [PATCH] fix(Icon): check whether the naming is correct --- src/common/utils.wxs | 5 +++++ src/icon/icon.wxml | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/utils.wxs b/src/common/utils.wxs index 3090b300d..1e023ebc3 100644 --- a/src/common/utils.wxs +++ b/src/common/utils.wxs @@ -124,6 +124,10 @@ function _style(styles) { return styles; } +function isValidIconName(str) { + return getRegExp('^[A-Za-z0-9\-]+$').test(str); +} + module.exports = { addUnit: addUnit, isString: isString, @@ -134,4 +138,5 @@ module.exports = { cls: cls, getBadgeAriaLabel: getBadgeAriaLabel, _style: _style, + isValidIconName: isValidIconName, }; diff --git a/src/icon/icon.wxml b/src/icon/icon.wxml index 914693992..bfa4de83e 100644 --- a/src/icon/icon.wxml +++ b/src/icon/icon.wxml @@ -11,5 +11,9 @@ - +