Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Row): use getCssVarsValue function, and comparing sizes with units #2734

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/_util/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,19 @@ export const getAttach = (node: any): HTMLElement => {
};

// 获取 css vars
export const getCssVarsValue = (name: string, element?: HTMLElement) => {
if (!canUseDocument) return;
export function getCssVarsValue(name: string, withUnit?: false, element?: HTMLElement): number | undefined;
export function getCssVarsValue(name: string, withUnit: true, element?: HTMLElement): string | undefined;
export function getCssVarsValue(name: string, withUnit: any, element?: HTMLElement): any {
Copy link
Collaborator

Choose a reason for hiding this comment

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

对于内部来说可能算是一个 bug 在内部,但是这个函数暴露到外面后,用户可能使用了这个函数进行数据处理,现在新增的变动可能导致一部分用户的使用方法被破坏。
如果你是想在 TDesign 内部使用的话,可以考虑重命名一个新的方法,然后代理新的方法。如果你是想在自己的项目使用的话,需要处理一下函数的兼容问题防止 break 到其他的用户,正式版本不做破坏性变更。

Copy link
Author

Choose a reason for hiding this comment

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

已修改

if (!canUseDocument) return undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (!canUseDocument) return undefined;
if (!canUseDocument) return;

没有实际意义的修改


const el = element || document.documentElement;
return getComputedStyle(el).getPropertyValue(name);
};
const value = getComputedStyle(el).getPropertyValue(name);

if (!withUnit) {
return Number.parseInt(value, 10);
}
return value;
}

/**
* 检查元素是否在父元素视图
Expand Down
Loading