Only mutate units when preceeded by a number
This commit is contained in:
parent
69d537325b
commit
e891f28fa6
1 changed files with 7 additions and 3 deletions
|
@ -18,10 +18,14 @@ utils.mutate = {
|
|||
},
|
||||
|
||||
units: function (str) {
|
||||
let mutator = function (m) {
|
||||
return random.number(4) === 1 ? m : make.unit.unit()
|
||||
let mutator = function (m, p1) {
|
||||
if (random.number(4) === 1) {
|
||||
return m
|
||||
} else {
|
||||
return p1 + make.unit.unit()
|
||||
}
|
||||
}
|
||||
return str.replace(/(px|em|ex|ch|rem|mm|cm|in|pt|pc|%')/g, mutator)
|
||||
return str.replace(/(\d*)(px|em|ex|ch|rem|mm|cm|in|pt|pc|%')/g, mutator)
|
||||
},
|
||||
|
||||
random: function (str) {
|
||||
|
|
Loading…
Reference in a new issue