Only mutate units when preceeded by a number

This commit is contained in:
pyoor 2017-08-16 15:57:57 -04:00
parent 69d537325b
commit e891f28fa6

View file

@ -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) {