Skip to content

Commit 57d17fc

Browse files
committed
Fix ES6 syntax for IE
1 parent 3982196 commit 57d17fc

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
1212
### Added
1313
* Support Node.js v12
1414
### Fixed
15+
* Fix object literal & arrow function syntax usage for IE.
1516

1617
2.4.1
1718
==================

browser.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const parseFont = require('./lib/parse-font')
55
exports.parseFont = parseFont
66

77
exports.createCanvas = function (width, height) {
8-
return Object.assign(document.createElement('canvas'), { width, height })
8+
return Object.assign(document.createElement('canvas'), { width: width, height: height })
99
}
1010

1111
exports.createImageData = function (array, width, height) {
@@ -19,16 +19,16 @@ exports.createImageData = function (array, width, height) {
1919
}
2020

2121
exports.loadImage = function (src, options) {
22-
return new Promise((resolve, reject) => {
22+
return new Promise(function (resolve, reject) {
2323
const image = Object.assign(document.createElement('img'), options)
2424

2525
function cleanup () {
2626
image.onload = null
2727
image.onerror = null
2828
}
2929

30-
image.onload = () => { cleanup(); resolve(image) }
31-
image.onerror = () => { cleanup(); reject(new Error(`Failed to load the image "${src}"`)) }
30+
image.onload = function () { cleanup(); resolve(image) }
31+
image.onerror = function () { cleanup(); reject(new Error('Failed to load the image "' + src + '"')) }
3232

3333
image.src = src
3434
})

lib/parse-font.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ const weights = 'bold|bolder|lighter|[1-9]00'
1414
// [ [ <‘font-style’> || <font-variant-css21> || <‘font-weight’> || <‘font-stretch’> ]?
1515
// <‘font-size’> [ / <‘line-height’> ]? <‘font-family’> ]
1616
// https://drafts.csswg.org/css-fonts-3/#font-prop
17-
const weightRe = new RegExp(`(${weights}) +`, 'i')
18-
const styleRe = new RegExp(`(${styles}) +`, 'i')
19-
const variantRe = new RegExp(`(${variants}) +`, 'i')
20-
const stretchRe = new RegExp(`(${stretches}) +`, 'i')
17+
const weightRe = new RegExp('(' + weights + ') +', 'i')
18+
const styleRe = new RegExp('(' + styles + ') +', 'i')
19+
const variantRe = new RegExp('(' + variants + ') +', 'i')
20+
const stretchRe = new RegExp('(' + stretches + ') +', 'i')
2121
const sizeFamilyRe = new RegExp(
2222
'([\\d\\.]+)(' + units + ') *'
2323
+ '((?:' + string + ')( *, *(?:' + string + '))*)')

0 commit comments

Comments
 (0)