From 57d17fc5557f826656169015bd537a23376398e9 Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Fri, 22 Mar 2019 10:57:27 -0500 Subject: [PATCH] Fix ES6 syntax for IE --- CHANGELOG.md | 1 + browser.js | 8 ++++---- lib/parse-font.js | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92cd47b8d..89fa2af15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Added * Support Node.js v12 ### Fixed +* Fix object literal & arrow function syntax usage for IE. 2.4.1 ================== diff --git a/browser.js b/browser.js index 3077111ca..0267a75a2 100644 --- a/browser.js +++ b/browser.js @@ -5,7 +5,7 @@ const parseFont = require('./lib/parse-font') exports.parseFont = parseFont exports.createCanvas = function (width, height) { - return Object.assign(document.createElement('canvas'), { width, height }) + return Object.assign(document.createElement('canvas'), { width: width, height: height }) } exports.createImageData = function (array, width, height) { @@ -19,7 +19,7 @@ exports.createImageData = function (array, width, height) { } exports.loadImage = function (src, options) { - return new Promise((resolve, reject) => { + return new Promise(function (resolve, reject) { const image = Object.assign(document.createElement('img'), options) function cleanup () { @@ -27,8 +27,8 @@ exports.loadImage = function (src, options) { image.onerror = null } - image.onload = () => { cleanup(); resolve(image) } - image.onerror = () => { cleanup(); reject(new Error(`Failed to load the image "${src}"`)) } + image.onload = function () { cleanup(); resolve(image) } + image.onerror = function () { cleanup(); reject(new Error('Failed to load the image "' + src + '"')) } image.src = src }) diff --git a/lib/parse-font.js b/lib/parse-font.js index a149c709c..ce03529e0 100644 --- a/lib/parse-font.js +++ b/lib/parse-font.js @@ -14,10 +14,10 @@ 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 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( '([\\d\\.]+)(' + units + ') *' + '((?:' + string + ')( *, *(?:' + string + '))*)')