File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
plugins/dominant-color-images Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,15 @@ function dominant_color_admin_script(): void {
225
225
let replaced = match.replace( /\sclass="/, " class=\"{{ data.hasTransparency ? \'has-transparency\' : \'not-transparent\' }} " );
226
226
replaced += ' data-dominant-color="{{ data.dominantColor }}"';
227
227
replaced += ' data-has-transparency="{{ data.hasTransparency }}"';
228
- replaced += ' style="--dominant-color: #{{ data.dominantColor }};"'; // TODO: Potentially there could be a style attribute as well!
228
+ let hasStyleAttr = false;
229
+ const colorStyle = '--dominant-color: #{{ data.dominantColor }};';
230
+ replaced = replaced.replace( /\sstyle="/, ( styleMatch ) => {
231
+ hasStyleAttr = true;
232
+ return styleMatch + colorStyle;
233
+ } );
234
+ if ( ! hasStyleAttr ) {
235
+ replaced += ` style="${colorStyle}"`;
236
+ }
229
237
return replaced;
230
238
} );
231
239
}
You can’t perform that action at this time.
0 commit comments