(runtime)
| 105 | } |
| 106 | |
| 107 | function toCss(runtime) { |
| 108 | if (!runtime) { |
| 109 | return ( |
| 110 | `:root { |
| 111 | |
| 112 | }`); |
| 113 | } |
| 114 | |
| 115 | if (runtime.default) { |
| 116 | const css: string[] = []; |
| 117 | Object.keys(runtime).forEach((pseudo) => { |
| 118 | if (pseudo === 'extra') { |
| 119 | Array.isArray(runtime.extra) && css.push(runtime.extra.join('\n')); |
| 120 | return; |
| 121 | } |
| 122 | // 只需要对这四种做兼容 |
| 123 | const prefix = pseudoMap.indexOf(pseudo) > -1 ? ':' : ''; |
| 124 | css.push( |
| 125 | `:root${pseudo === 'default' ? '' : `${prefix}${pseudo}`} { |
| 126 | ${runtimeToCss(normalizeStyle(runtime[pseudo]))} |
| 127 | }\n`, |
| 128 | ); |
| 129 | }); |
| 130 | return css.join('\n'); |
| 131 | } |
| 132 | |
| 133 | return ( |
| 134 | `:root { |
| 135 | ${runtimeToCss(normalizeStyle(runtime))} |
| 136 | } |
| 137 | ` |
| 138 | ); |
| 139 | } |
| 140 | |
| 141 | function cssToRuntime(css: string) { |
| 142 | if (!css) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…