Skip to content

Commit 8c482db

Browse files
authored
Merge pull request #15012 from jbaicoianu/worker-fixes
Fix undefined object errors when loading assets in workers
2 parents d3bd4db + 9d57a0d commit 8c482db

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/extras/ImageUtils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ var ImageUtils = {
1010

1111
var canvas;
1212

13-
if ( image instanceof HTMLCanvasElement ) {
13+
if ( typeof HTMLCanvasElement == 'undefined' ) {
14+
15+
return image.src;
16+
17+
} else if ( image instanceof HTMLCanvasElement ) {
1418

1519
canvas = image;
1620

src/loaders/FileLoader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ Object.assign( FileLoader.prototype, {
7070
var isBase64 = !! dataUriRegexResult[ 2 ];
7171
var data = dataUriRegexResult[ 3 ];
7272

73-
data = window.decodeURIComponent( data );
73+
data = decodeURIComponent( data );
7474

75-
if ( isBase64 ) data = window.atob( data );
75+
if ( isBase64 ) data = atob( data );
7676

7777
try {
7878

@@ -126,7 +126,7 @@ Object.assign( FileLoader.prototype, {
126126
}
127127

128128
// Wait for next browser tick like standard XMLHttpRequest event dispatching does
129-
window.setTimeout( function () {
129+
setTimeout( function () {
130130

131131
if ( onLoad ) onLoad( response );
132132

@@ -137,7 +137,7 @@ Object.assign( FileLoader.prototype, {
137137
} catch ( error ) {
138138

139139
// Wait for next browser tick like standard XMLHttpRequest event dispatching does
140-
window.setTimeout( function () {
140+
setTimeout( function () {
141141

142142
if ( onError ) onError( error );
143143

0 commit comments

Comments
 (0)