This commit is contained in:
那些花儿
2025-09-18 15:57:10 +08:00
parent b05de4830c
commit 241d207034
6 changed files with 61 additions and 19 deletions
@@ -19,7 +19,7 @@ const styleUtil = {
// }
// }
// 使用TreeWalker优化遍历性能
// 查找本组件的子元素 但是排除掉VUE组件 使用TreeWalker优化遍历性能
const walker = document.createTreeWalker(
el,
NodeFilter.SHOW_ELEMENT,
@@ -51,16 +51,6 @@ const styleUtil = {
// 处理根元素
el.removeAttribute(scopedId);
// if (el && el.removeAttribute) {
// el.removeAttribute(scopedId)
//
// // 递归处理所有子元素
// const children = el.children || el.childNodes
// for (let i = 0; i < children.length; i++) {
// styleUtil.removeScopedAttribute(children[i], scopedId)
// }
// }
},
// 为CSS规则添加作用域属性
@@ -72,11 +62,15 @@ const styleUtil = {
const processedSelectors = selectors.split(',')
.map(selector => {
selector = selector.trim();
// 处理深度选择器
if (selector.includes('::v-deep')) {
return selector.replace('::v-deep', `[${scopedId}]`);
}
if(selector.includes("/deep/")){
return selector.replace('/deep/', `[${scopedId}]`);
}
// 处理媒体查询等特殊情况
if (selector.includes('@') || selector.startsWith('@')) {