@@ -5353,9 +5353,13 @@ Worker.prototype.save = function save(filename) {
53535353/* ----- SET / GET ----- */
53545354
53555355Worker . prototype . set = function set$$1 ( opt ) {
5356- // TODO: Test null/undefined input to this function.
53575356 // TODO: Implement ordered pairs?
53585357
5358+ // Silently ignore invalid or empty input.
5359+ if ( objType ( opt ) !== 'object' ) {
5360+ return this ;
5361+ }
5362+
53595363 // Build an array of setter functions to queue.
53605364 var fns = Object . keys ( opt || { } ) . map ( function ( key ) {
53615365 if ( key in Worker . template . prop ) {
@@ -5474,9 +5478,12 @@ Worker.prototype.then = function then(onFulfilled, onRejected) {
54745478 onRejected = onRejected . bind ( self ) ;
54755479 }
54765480
5481+ // Cast self into a Promise to avoid es6-promise recursively defining `then`.
5482+ var selfPromise = '_state' in self ? Worker . convert ( _extends ( { } , self ) , Promise . prototype ) : self ;
5483+
54775484 // Update progress while queuing, calling, and resolving `then`.
54785485 self . updateProgress ( null , null , 1 , [ onFulfilled ] ) ;
5479- var returnVal = Promise . prototype . then . call ( self , function then_pre ( val ) {
5486+ var returnVal = Promise . prototype . then . call ( selfPromise , function then_pre ( val ) {
54805487 self . updateProgress ( null , onFulfilled ) ;
54815488 return val ;
54825489 } ) . then ( onFulfilled , onRejected ) . then ( function then_post ( val ) {
@@ -5500,8 +5507,11 @@ Worker.prototype.thenCore = function thenCore(onFulfilled, onRejected) {
55005507 onRejected = onRejected . bind ( self ) ;
55015508 }
55025509
5510+ // Cast self into a Promise to avoid es6-promise recursively defining `then`.
5511+ var selfPromise = '_state' in self ? Worker . convert ( _extends ( { } , self ) , Promise . prototype ) : self ;
5512+
55035513 // Return the promise, after casting it into a Worker and preserving props.
5504- var returnVal = Promise . prototype . then . call ( self , onFulfilled , onRejected ) ;
5514+ var returnVal = Promise . prototype . then . call ( selfPromise , onFulfilled , onRejected ) ;
55055515 return Worker . convert ( returnVal , self . __proto__ ) ;
55065516} ;
55075517
0 commit comments