From dca33f70a2d455ce49194ef76fc19fed5d945c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Thu, 21 Dec 2017 00:39:13 +0000 Subject: [PATCH] Fix Node.js 0.x compatibility --- lib/parse-font.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/parse-font.js b/lib/parse-font.js index cf91b6e61..5d1854cbf 100644 --- a/lib/parse-font.js +++ b/lib/parse-font.js @@ -4,7 +4,7 @@ * Font RegExp helpers. */ -const weights = 'bold|bolder|lighter|[1-9]00' +var weights = 'bold|bolder|lighter|[1-9]00' , styles = 'italic|oblique' , variants = 'small-caps' , stretches = 'ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded' @@ -14,11 +14,11 @@ const weights = 'bold|bolder|lighter|[1-9]00' // [ [ <‘font-style’> || || <‘font-weight’> || <‘font-stretch’> ]? // <‘font-size’> [ / <‘line-height’> ]? <‘font-family’> ] // https://drafts.csswg.org/css-fonts-3/#font-prop -const weightRe = new RegExp(`(${weights}) +`, 'i') -const styleRe = new RegExp(`(${styles}) +`, 'i') -const variantRe = new RegExp(`(${variants}) +`, 'i') -const stretchRe = new RegExp(`(${stretches}) +`, 'i') -const sizeFamilyRe = new RegExp( +var weightRe = new RegExp('(' + weights + ') +', 'i') +var styleRe = new RegExp('(' + styles + ') +', 'i') +var variantRe = new RegExp('(' + variants + ') +', 'i') +var stretchRe = new RegExp('(' + stretches + ') +', 'i') +var sizeFamilyRe = new RegExp( '([\\d\\.]+)(' + units + ') *' + '((?:' + string + ')( *, *(?:' + string + '))*)') @@ -26,9 +26,9 @@ const sizeFamilyRe = new RegExp( * Cache font parsing. */ -const cache = {} +var cache = {} -const defaultHeight = 16 // pt, common browser default +var defaultHeight = 16 // pt, common browser default /** * Parse font `str`. @@ -44,11 +44,11 @@ module.exports = function (str) { if (cache[str]) return cache[str] // Try for required properties first. - const sizeFamily = sizeFamilyRe.exec(str) + var sizeFamily = sizeFamilyRe.exec(str) if (!sizeFamily) return // invalid // Default values and required properties - const font = { + var font = { weight: 'normal', style: 'normal', stretch: 'normal', @@ -59,9 +59,9 @@ module.exports = function (str) { } // Optional, unordered properties. - let weight, style, variant, stretch + var weight, style, variant, stretch // Stop search at `sizeFamily.index` - let substr = str.substring(0, sizeFamily.index) + var substr = str.substring(0, sizeFamily.index) if ((weight = weightRe.exec(substr))) font.weight = weight[1] if ((style = styleRe.exec(substr))) font.style = style[1] if ((variant = variantRe.exec(substr))) font.variant = variant[1]