Skip to content

Conversation

@wenwenhua
Copy link
Collaborator

@wenwenhua wenwenhua commented Jan 5, 2026

1.z-index auto 报错编译提示
2.样式编译优化:es6语法+__formatValue简化
3.去掉 translate & border-radius 的百分比计算 & 保留 translateY calc(100% - 20px)的百分比计算
4.去掉非媒体查询场景下的_default&_media字段
5.image 组件Android下保持计算border radius 百分比

回撤改动:
支持transform 分开定义 css var 且包含未定义值的var变量,如 --un-translate-x: -50%;transform translateX(var(--un-translate-x)) translateY(var(--un-translate-y));

@wenwenhua wenwenhua changed the title Feat style compile 251012 ms 样式相关优化 Jan 5, 2026
return { prop, value: values[0].trim() }
}

const formatZIndex = ({ prop, value, selector }, { mode }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥不走verifyValues来校验实现?

function calcVisitor ({ key, value, keyPath }: VisitorArg) {
if (calcUseRegExp.test(value)) {
// calc translate & border-radius 的百分比计算
if (hasOwn(selfPercentRule, key) && /%/.test(value)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

走正则校验严谨一点,声明个内含百分比的正则表达式

// transform z-index auto to 0
transformZIndex(normalStyle)
if (Array.isArray(normalStyle.transform)) {
normalStyle.transform = normalStyle.transform.filter(item => !isEmptyObject(item))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥要改这个

}, '')
}

function transformZIndex (styleObj: Record<string, any>) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没必要加这个吧,如果这玩意需要运行时校验那要加的可太多了。。。

[ValueType.enum]: `${SUPPORTED_PROP_VAL_ARR[prop]?.join(',')}`
}
tips(`Value of ${prop} in ${selector} should be ${type}, eg ${info[type]}, received [${value}], please check again!`)
tips(`Value of ${prop} in ${selector} should be ${type}${info[type] ? `, eg ${info[type]}` : ''}, received [${value}], please check again!`)
Copy link
Collaborator

@hiyuki hiyuki Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类型校验细化一点吧,之前的定义的那个number应该叫length,对于z-index这种只允许纯数字的叫integer

function calcVisitor ({ key, value, keyPath }: VisitorArg) {
if (calcUseRegExp.test(value)) {
// calc translate & border-radius 的百分比计算
if (hasOwn(selfPercentRule, key) && /calc\(\d+%/.test(value)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考一下percentReg, +-和小数得支持

borderTopRightRadius: 'width',
borderRadius: 'width'
}
const selfPercentRule: Record<string, 'height' | 'width'> = Object.assign({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.assign => extend

parentFontSize?: number
parentWidth?: number
parentHeight?: number
isTransformBorderRadiusPercent?: boolean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

简化一下:transformRadiusPercent

@hiyuki hiyuki merged commit fa3b920 into master Jan 23, 2026
6 checks passed
@hiyuki hiyuki deleted the feat-style-compile-251012-ms branch January 23, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants