Skip to content

Commit 4788318

Browse files
committed
Rebuild with es6-promise recursion fix
1 parent 691024b commit 4788318

File tree

6 files changed

+54
-14
lines changed

6 files changed

+54
-14
lines changed

dist/html2pdf.bundle.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5353,9 +5353,13 @@ Worker.prototype.save = function save(filename) {
53535353
/* ----- SET / GET ----- */
53545354

53555355
Worker.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

dist/html2pdf.bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/html2pdf.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,13 @@ Worker.prototype.save = function save(filename) {
412412
/* ----- SET / GET ----- */
413413

414414
Worker.prototype.set = function set$$1(opt) {
415-
// TODO: Test null/undefined input to this function.
416415
// TODO: Implement ordered pairs?
417416

417+
// Silently ignore invalid or empty input.
418+
if (objType(opt) !== 'object') {
419+
return this;
420+
}
421+
418422
// Build an array of setter functions to queue.
419423
var fns = Object.keys(opt || {}).map(function (key) {
420424
if (key in Worker.template.prop) {
@@ -533,9 +537,12 @@ Worker.prototype.then = function then(onFulfilled, onRejected) {
533537
onRejected = onRejected.bind(self);
534538
}
535539

540+
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
541+
var selfPromise = '_state' in self ? Worker.convert(_extends({}, self), Promise.prototype) : self;
542+
536543
// Update progress while queuing, calling, and resolving `then`.
537544
self.updateProgress(null, null, 1, [onFulfilled]);
538-
var returnVal = Promise.prototype.then.call(self, function then_pre(val) {
545+
var returnVal = Promise.prototype.then.call(selfPromise, function then_pre(val) {
539546
self.updateProgress(null, onFulfilled);
540547
return val;
541548
}).then(onFulfilled, onRejected).then(function then_post(val) {
@@ -559,8 +566,11 @@ Worker.prototype.thenCore = function thenCore(onFulfilled, onRejected) {
559566
onRejected = onRejected.bind(self);
560567
}
561568

569+
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
570+
var selfPromise = '_state' in self ? Worker.convert(_extends({}, self), Promise.prototype) : self;
571+
562572
// Return the promise, after casting it into a Worker and preserving props.
563-
var returnVal = Promise.prototype.then.call(self, onFulfilled, onRejected);
573+
var returnVal = Promise.prototype.then.call(selfPromise, onFulfilled, onRejected);
564574
return Worker.convert(returnVal, self.__proto__);
565575
};
566576

dist/html2pdf.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/include/html2pdf.es.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,13 @@ Worker.prototype.save = function save(filename) {
407407
/* ----- SET / GET ----- */
408408

409409
Worker.prototype.set = function set$$1(opt) {
410-
// TODO: Test null/undefined input to this function.
411410
// TODO: Implement ordered pairs?
412411

412+
// Silently ignore invalid or empty input.
413+
if (objType(opt) !== 'object') {
414+
return this;
415+
}
416+
413417
// Build an array of setter functions to queue.
414418
var fns = Object.keys(opt || {}).map(function (key) {
415419
if (key in Worker.template.prop) {
@@ -528,9 +532,12 @@ Worker.prototype.then = function then(onFulfilled, onRejected) {
528532
onRejected = onRejected.bind(self);
529533
}
530534

535+
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
536+
var selfPromise = '_state' in self ? Worker.convert(_extends({}, self), Promise.prototype) : self;
537+
531538
// Update progress while queuing, calling, and resolving `then`.
532539
self.updateProgress(null, null, 1, [onFulfilled]);
533-
var returnVal = Promise.prototype.then.call(self, function then_pre(val) {
540+
var returnVal = Promise.prototype.then.call(selfPromise, function then_pre(val) {
534541
self.updateProgress(null, onFulfilled);
535542
return val;
536543
}).then(onFulfilled, onRejected).then(function then_post(val) {
@@ -554,8 +561,11 @@ Worker.prototype.thenCore = function thenCore(onFulfilled, onRejected) {
554561
onRejected = onRejected.bind(self);
555562
}
556563

564+
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
565+
var selfPromise = '_state' in self ? Worker.convert(_extends({}, self), Promise.prototype) : self;
566+
557567
// Return the promise, after casting it into a Worker and preserving props.
558-
var returnVal = Promise.prototype.then.call(self, onFulfilled, onRejected);
568+
var returnVal = Promise.prototype.then.call(selfPromise, onFulfilled, onRejected);
559569
return Worker.convert(returnVal, self.__proto__);
560570
};
561571

dist/require/html2pdf.cjs.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,13 @@ Worker.prototype.save = function save(filename) {
411411
/* ----- SET / GET ----- */
412412

413413
Worker.prototype.set = function set$$1(opt) {
414-
// TODO: Test null/undefined input to this function.
415414
// TODO: Implement ordered pairs?
416415

416+
// Silently ignore invalid or empty input.
417+
if (objType(opt) !== 'object') {
418+
return this;
419+
}
420+
417421
// Build an array of setter functions to queue.
418422
var fns = Object.keys(opt || {}).map(function (key) {
419423
if (key in Worker.template.prop) {
@@ -532,9 +536,12 @@ Worker.prototype.then = function then(onFulfilled, onRejected) {
532536
onRejected = onRejected.bind(self);
533537
}
534538

539+
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
540+
var selfPromise = '_state' in self ? Worker.convert(_extends({}, self), Promise.prototype) : self;
541+
535542
// Update progress while queuing, calling, and resolving `then`.
536543
self.updateProgress(null, null, 1, [onFulfilled]);
537-
var returnVal = Promise.prototype.then.call(self, function then_pre(val) {
544+
var returnVal = Promise.prototype.then.call(selfPromise, function then_pre(val) {
538545
self.updateProgress(null, onFulfilled);
539546
return val;
540547
}).then(onFulfilled, onRejected).then(function then_post(val) {
@@ -558,8 +565,11 @@ Worker.prototype.thenCore = function thenCore(onFulfilled, onRejected) {
558565
onRejected = onRejected.bind(self);
559566
}
560567

568+
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
569+
var selfPromise = '_state' in self ? Worker.convert(_extends({}, self), Promise.prototype) : self;
570+
561571
// Return the promise, after casting it into a Worker and preserving props.
562-
var returnVal = Promise.prototype.then.call(self, onFulfilled, onRejected);
572+
var returnVal = Promise.prototype.then.call(selfPromise, onFulfilled, onRejected);
563573
return Worker.convert(returnVal, self.__proto__);
564574
};
565575

0 commit comments

Comments
 (0)