-
Notifications
You must be signed in to change notification settings - Fork 319
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
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 { | ||||||
if (!canUseDocument) return undefined; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
没有实际意义的修改 |
||||||
|
||||||
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; | ||||||
} | ||||||
|
||||||
/** | ||||||
* 检查元素是否在父元素视图 | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于内部来说可能算是一个 bug 在内部,但是这个函数暴露到外面后,用户可能使用了这个函数进行数据处理,现在新增的变动可能导致一部分用户的使用方法被破坏。
如果你是想在 TDesign 内部使用的话,可以考虑重命名一个新的方法,然后代理新的方法。如果你是想在自己的项目使用的话,需要处理一下函数的兼容问题防止 break 到其他的用户,正式版本不做破坏性变更。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改