使用Flexbox布局时,css解析有问题
- Dominant language
- Objective-C
- Stars
- 3.7k
- Forks
- 759
- PR merge metrics
- No merged PRs in 30d
Description
### 问题
```
```
这样的写法,会报错:
```
space_between isn't a valid key in valid Dic {
center = 1;
"flex-end" = 2;
"flex-start" = 0;
"space-around" = 4;
"space-between" = 3;
}
```
### 原因
原因是对css的解析不严谨,将css字符串整体将`-`替换为`_`,之后对css属性替换回来,值没有替换回来。
```
elseif (_v.name == "css") then
_v.value = _gsub(_v.value, "-","_")
local paramFun = sys:loadstring("return " .. _v.value)
local t = paramFun()
local css = ""
for _k, _v in pairs(t) do
_k = _gsub(_k, "_","-")
if (_find(_k, "margin")) then
css = css .. _k .. ":" .. _v*sys.scale .. ","
else
css = css .. _k .. ":" .. _v .. ","
end
end
```
https://github.com/alibaba/LuaViewSDK/blob/master/IOS/luaviewEx/luaviewEx/Assets/kit/pica.lua#L180
Contributor guide
No contributing guide indexed for this repository
Research direction
Open Assets/kit/pica.lua around line 180 and read the CSS parsing branch shown in the issue. Reproduce the View example with justify-content set to space-between, then verify that the parser accepts the hyphenated value and produces the expected CSS output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, lua
- Domain
- frontend, mobile-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100