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) { units: function (str) {
let mutator = function (m) { let mutator = function (m, p1) {
return random.number(4) === 1 ? m : make.unit.unit() 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) { random: function (str) {