Skip to content

Commit d28acca

Browse files
fix(taro-framework-solid): 修复Solid框架的类名空格分隔问题 (#17552)
* fix(taro-framework-solid): 修复类名空格分隔问题 - 在 updateClassList 函数中,对类名进行空格分隔处理 - 确保类名中的每个部分都能正确添加或移除 * fix(taro-framework-solid): 修复类名更新逻辑 - 修正了 updateClassList 函数中的类名处理逻辑 * fix(taro-framework-solid): 使用正则表达式替换原有的空格分割方法 - 使用 trim 方法消除收尾空格 - 使用正则表达式替换原有的空格分割方法,以适应多个连续空格的情况 --------- Co-authored-by: vasily <[email protected]>
1 parent f194562 commit d28acca

File tree

1 file changed

+4
-2
lines changed
  • packages/taro-framework-solid/src/reconciler

1 file changed

+4
-2
lines changed

packages/taro-framework-solid/src/reconciler/props.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ export function setProperty (
6767

6868
function updateClassList (dom: TaroElement, newValue: ClassList) {
6969
const [addList, removeList]: [string[], string[]] = [[], []]
70+
const regexp = /\s+/
7071
for (const key in newValue) {
7172
if (newValue[key]) {
72-
addList.push(key)
73+
// 处理classList中包含空格分隔的类名
74+
key.trim().split(regexp).forEach(className => addList.push(className))
7375
} else {
74-
removeList.push(key)
76+
key.trim().split(regexp).forEach(className => removeList.push(className))
7577
}
7678
}
7779
(dom.classList as any).add(...addList);

0 commit comments

Comments
 (0)