Skip to content

Commit

Permalink
Fix ES6 syntax for IE
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuggins committed Apr 28, 2019
1 parent 3982196 commit 57d17fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
==================
Expand Down
8 changes: 4 additions & 4 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -19,16 +19,16 @@ 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 () {
image.onload = null
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
})
Expand Down
8 changes: 4 additions & 4 deletions lib/parse-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const weights = 'bold|bolder|lighter|[1-9]00'
// [ [ <‘font-style’> || <font-variant-css21> || <‘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 + '))*)')
Expand Down

0 comments on commit 57d17fc

Please sign in to comment.