Skip to content

Commit

Permalink
fix: factor hueRegexp out of the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 3, 2021
1 parent 4585437 commit 703c75c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/dom-styles-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default class DOMStylesReader {

const dotRegexp = /\.+/g
const rgbExtractRegexp = /rgb(a?)\((\d+), (\d+), (\d+)(, (\d+(\.\d+)?))?\)/
const hueRegexp = /hue-rotate\((\d+)deg\)/

/**
* Computes the output color of `value` with a rotated hue defined
Expand All @@ -148,7 +149,7 @@ function rotateHue (value, filter) {
const match = value.match(rgbExtractRegexp)
let [, , r, g, b, , a] = match

let [, hue] = filter.match(/hue-rotate\((\d+)deg\)/)
let [, hue] = filter.match(hueRegexp)

;[r, g, b, a, hue] = [r, g, b, a, hue].map(Number)
;[r, g, b] = rotate(r, g, b, hue)
Expand Down

0 comments on commit 703c75c

Please sign in to comment.