(style: string | null, px2number = true)
| 26 | }); |
| 27 | |
| 28 | function formatStyleObject(style: string | null, px2number = true) { |
| 29 | if (!style) { |
| 30 | return {}; |
| 31 | } |
| 32 | |
| 33 | // 去除注释 /* xx */ |
| 34 | style = style.replace(/\/\*[^(\*\/)]*\*\//g, ''); |
| 35 | |
| 36 | const res: any = {}; |
| 37 | style.split(';').forEach((item: string) => { |
| 38 | if (!item || !String(item).includes(':')) return; |
| 39 | |
| 40 | const [key, value] = item.split(':'); |
| 41 | |
| 42 | res[String(key).trim()] = |
| 43 | px2number && value.endsWith('px') |
| 44 | ? Number(String(value).replace(/px$/, '')) |
| 45 | : String(value).trim(); |
| 46 | }); |
| 47 | |
| 48 | return res; |
| 49 | } |
| 50 | |
| 51 | test('Renderer:PopOver in table', async () => { |
| 52 | const {container, rerender, getByText} = render( |
no test coverage detected