File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/components/ThemePicker Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -67,11 +67,18 @@ export default {
67
67
68
68
methods: {
69
69
updateStyle (style , oldCluster , newCluster ) {
70
- let newStyle = style
70
+ const colorOverrides = [] // only capture color overides
71
71
oldCluster .forEach ((color , index ) => {
72
- newStyle = newStyle .replace (new RegExp (color, ' ig' ), newCluster[index])
72
+ const value = newCluster[index]
73
+ const color_plain = color .replace (/ ([()] )/ g , ' \\ $1' )
74
+ const repl = new RegExp (` (^|})([^{]+{[^{}]+)${ color_plain} \\ b([^}]*)(?=})` , ' gi' )
75
+ const nestRepl = new RegExp (color_plain, ' ig' ) // for greed matching before the 'color'
76
+ let v
77
+ while ((v = repl .exec (style))) {
78
+ colorOverrides .push (v[2 ].replace (nestRepl, value) + value + v[3 ] + ' }' ) // '}' not captured in the regexp repl to reserve it as locator-boundary
79
+ }
73
80
})
74
- return newStyle
81
+ return colorOverrides . join ( ' ' )
75
82
},
76
83
77
84
getCSSString (url , callback , variable ) {
You can’t perform that action at this time.
0 commit comments