convertToNum = (attr, val) => {
  // Return a number if that's what it already is
  if (!isNaN(val)) { return val - 0 }
  if (val.substr(-1) === '%') {
    // Deal with percentage, depends on attribute
    const num = val.substr(0, val.length - 1) / 100
    const width = elementContainer_.getWidth()
    const height = elementContainer_.getHeight()

    if (wAttrs.includes(attr)) {
      return num * width
    }
    if (hAttrs.includes(attr)) {
      return num * height
    }
    return num * Math.sqrt((width * width) + (height * height)) / Math.sqrt(2)
  }
  const unit = val.substr(-2)
  const num = val.substr(0, val.length - 2)
  // Note that this multiplication turns the string into a number
  return num * typeMap_[unit]
}
Converts given values to numbers. Attributes must be supplied in
case a percentage is given.

@function module:units.convertToNum
@param {string} attr - Name of the attribute associated with the value
@param {string} val - Attribute value to convert
@returns {Float} The converted number