-
Notifications
You must be signed in to change notification settings - Fork 380
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 transform var #1772
Open
wenwenhua
wants to merge
10
commits into
master
Choose a base branch
from
bugfix-hjw-241220
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix transform var #1772
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5326576
fix transform var
wenwenhua b6f616c
add cssVariableExp
wenwenhua e39567f
Merge branch 'master' into bugfix-hjw-241220
hiyuki 664bb70
add parseValueFromParentheses 解析 translateY(10px)
wenwenhua 0973c36
Merge branch 'bugfix-hjw-241220' of github.com:didi/mpx into bugfix-h…
wenwenhua ad20862
add parseValueFromParentheses 解析 translateY(10px)
wenwenhua 3f781aa
fix Parentheses
wenwenhua 7ad1e61
Merge branch 'master' into bugfix-hjw-241220
hiyuki eb8a771
fix del parseValueFromParentheses & update match transform
wenwenhua 2a73cad
fix match exp
wenwenhua 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 |
---|---|---|
|
@@ -374,11 +374,11 @@ module.exports = function getSpec ({ warn, error }) { | |
// transform 转换 | ||
const formatTransform = ({ prop, value, selector }, { mode }) => { | ||
// css var & 数组直接返回 | ||
if (Array.isArray(value) || calcExp.test(value)) return { prop, value } | ||
if (Array.isArray(value) || cssVariableExp.test(value)) return { prop, value } | ||
const values = parseValues(value) | ||
const transform = [] | ||
values.forEach(item => { | ||
const match = item.match(/([/\w]+)\(([^)]+)\)/) | ||
const match = item.match(/([/\w]+)\(([^]+)\)/) | ||
if (match && match.length >= 3) { | ||
let key = match[1] | ||
const val = match[2] | ||
|
@@ -407,23 +407,23 @@ module.exports = function getSpec ({ warn, error }) { | |
case 'rotate3d': // x y z angle | ||
case 'translate3d': // x y 支持 z不支持 | ||
case 'scale3d': // x y 支持 z不支持 | ||
{ | ||
// 2 个以上的值处理 | ||
key = key.replace('3d', '') | ||
const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3) | ||
// scale(.5) === scaleX(.5) scaleY(.5) | ||
if (vals.length === 1 && key === 'scale') { | ||
vals.push(vals[0]) | ||
} | ||
const xyz = ['X', 'Y', 'Z'] | ||
transform.push(...vals.map((v, index) => { | ||
if (key !== 'rotate' && index > 1) { | ||
unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode }) | ||
} | ||
return { [`${key}${xyz[index] || ''}`]: v.trim() } | ||
})) | ||
break | ||
{ | ||
// 2 个以上的值处理 | ||
key = key.replace('3d', '') | ||
const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3) | ||
// scale(.5) === scaleX(.5) scaleY(.5) | ||
if (vals.length === 1 && key === 'scale') { | ||
vals.push(vals[0]) | ||
} | ||
const xyz = ['X', 'Y', 'Z'] | ||
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. 这块为啥会有diff |
||
transform.push(...vals.map((v, index) => { | ||
if (key !== 'rotate' && index > 1) { | ||
unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode }) | ||
} | ||
return { [`${key}${xyz[index] || ''}`]: v.trim() } | ||
})) | ||
break | ||
} | ||
case 'translateZ': | ||
case 'scaleZ': | ||
default: | ||
|
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 |
---|---|---|
|
@@ -110,7 +110,7 @@ const parseTransform = (transformStr: string) => { | |
const values = parseValues(transformStr) | ||
const transform: {[propName: string]: string|number|number[]}[] = [] | ||
values.forEach(item => { | ||
const match = item.match(/([/\w]+)\(([^)]+)\)/) | ||
const match = item.match(/([/\w]+)\(([^]+)\)/) | ||
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. 如上 |
||
if (match && match.length >= 3) { | ||
let key = match[1] | ||
const val = match[2] | ||
|
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.
[^]+是个啥。。。写为.+