Skip to content

Commit

Permalink
fix: avoid ES6+ syntax in client scripts (#3629)
Browse files Browse the repository at this point in the history
* remove template literals and arrow functions that break in IE11 
Fixes #3630
  • Loading branch information
longlho authored Jan 25, 2021
1 parent e246461 commit 6629e96
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
7 changes: 4 additions & 3 deletions client/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)
}

socket.emit('karma_error', message)
self.updater.updateTestStatus(`karma_error ${message}`)
self.updater.updateTestStatus('karma_error ' + message)
this.complete()
return false
}
Expand Down Expand Up @@ -240,8 +240,9 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)

// A test could have incorrectly issued a navigate. Wait one turn
// to ensure the error from an incorrect navigate is processed.
setTimeout(() => {
if (this.config.clearContext) {
var config = this.config
setTimeout(function () {
if (config.clearContext) {
navigateContextTo('about:blank')
}

Expand Down
22 changes: 11 additions & 11 deletions client/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
if (!titleElement || !bannerElement) {
return
}
titleElement.textContent = `Karma v ${VERSION} - ${connectionText}; test: ${testText}; ${pingText}`
titleElement.textContent = 'Karma v ' + VERSION + ' - ' + connectionText + '; test: ' + testText + '; ' + pingText
bannerElement.className = connectionText === 'connected' ? 'online' : 'offline'
}

Expand All @@ -46,32 +46,32 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
updateBanner()
}

socket.on('connect', () => {
socket.on('connect', function () {
updateConnectionStatus('connected')
})
socket.on('disconnect', () => {
socket.on('disconnect', function () {
updateConnectionStatus('disconnected')
})
socket.on('reconnecting', (sec) => {
updateConnectionStatus(`reconnecting in ${sec} seconds`)
socket.on('reconnecting', function (sec) {
updateConnectionStatus('reconnecting in ' + sec + ' seconds')
})
socket.on('reconnect', () => {
socket.on('reconnect', function () {
updateConnectionStatus('reconnected')
})
socket.on('reconnect_failed', () => {
socket.on('reconnect_failed', function () {
updateConnectionStatus('reconnect_failed')
})

socket.on('info', updateBrowsersInfo)
socket.on('disconnect', () => {
socket.on('disconnect', function () {
updateBrowsersInfo([])
})

socket.on('ping', () => {
socket.on('ping', function () {
updatePingStatus('ping...')
})
socket.on('pong', (latency) => {
updatePingStatus(`ping ${latency}ms`)
socket.on('pong', function (latency) {
updatePingStatus('ping ' + latency + 'ms')
})

return { updateTestStatus: updateTestStatus }
Expand Down
29 changes: 15 additions & 14 deletions static/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)
}

socket.emit('karma_error', message)
self.updater.updateTestStatus(`karma_error ${message}`)
self.updater.updateTestStatus('karma_error ' + message)
this.complete()
return false
}
Expand Down Expand Up @@ -250,8 +250,9 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)

// A test could have incorrectly issued a navigate. Wait one turn
// to ensure the error from an incorrect navigate is processed.
setTimeout(() => {
if (this.config.clearContext) {
var config = this.config
setTimeout(function () {
if (config.clearContext) {
navigateContextTo('about:blank')
}

Expand Down Expand Up @@ -384,7 +385,7 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
if (!titleElement || !bannerElement) {
return
}
titleElement.textContent = `Karma v ${VERSION} - ${connectionText}; test: ${testText}; ${pingText}`
titleElement.textContent = 'Karma v ' + VERSION + ' - ' + connectionText + '; test: ' + testText + '; ' + pingText
bannerElement.className = connectionText === 'connected' ? 'online' : 'offline'
}

Expand All @@ -401,32 +402,32 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
updateBanner()
}

socket.on('connect', () => {
socket.on('connect', function () {
updateConnectionStatus('connected')
})
socket.on('disconnect', () => {
socket.on('disconnect', function () {
updateConnectionStatus('disconnected')
})
socket.on('reconnecting', (sec) => {
updateConnectionStatus(`reconnecting in ${sec} seconds`)
socket.on('reconnecting', function (sec) {
updateConnectionStatus('reconnecting in ' + sec + ' seconds')
})
socket.on('reconnect', () => {
socket.on('reconnect', function () {
updateConnectionStatus('reconnected')
})
socket.on('reconnect_failed', () => {
socket.on('reconnect_failed', function () {
updateConnectionStatus('reconnect_failed')
})

socket.on('info', updateBrowsersInfo)
socket.on('disconnect', () => {
socket.on('disconnect', function () {
updateBrowsersInfo([])
})

socket.on('ping', () => {
socket.on('ping', function () {
updatePingStatus('ping...')
})
socket.on('pong', (latency) => {
updatePingStatus(`ping ${latency}ms`)
socket.on('pong', function (latency) {
updatePingStatus('ping ' + latency + 'ms')
})

return { updateTestStatus: updateTestStatus }
Expand Down

0 comments on commit 6629e96

Please sign in to comment.