Hi! This library is great, thanks so much for making it! 馃挅
Is there a need to only set printWindow.onload = null; in IE? Seems like that could run regardless of browser right?
Some backing context for why I'd like to remove that line: https://codesandbox.io/s/react-to-print-infinite-onloads-h4mnr infinitely hangs when running tests.
printWindow's onload, even though it's only been set once.act in the test to never complete...onBeforeLoad function never gets called if you use a synchronous act.You can verify this by cloning the sandbox locally, prettifying the compiled index.js, and adding console logs.
console.log("Setting onload");
f.onload = function() {
console.log("Calling onload");
window.navigator && window.navigator.userAgent.indexOf("Trident/7.0") > -1 && (f.onload = null);
console.log
Setting onload
at e.handlePrint (node_modules/react-to-print/lib/index.js:109:35)
console.log
Calling onload
at HTMLIFrameElement.f.onload (node_modules/react-to-print/lib/index.js:111:37)
console.log
Calling onload
at HTMLIFrameElement.f.onload (node_modules/react-to-print/lib/index.js:111:37)
console.log
Calling onload
at HTMLIFrameElement.f.onload (node_modules/react-to-print/lib/index.js:111:37)
...
Now, this seems like a bug in Enzyme and should probably be fixed there (https://github.com/enzymejs/enzyme/issues/2400), _but_ it would be fixed by this already-seemingly-positive change.
Hi, thanks for the report. That does seem like an interesting issue. And I agree, I don't see why we can't just always clear out the event listener. I'll get it in with some changes I'm making tonight!
Should be fixed in the just published 2.9.0, let me know if you see any issues.
Also, if you ever wanted to help us move from tslint to eslint, would appreciate any support there :)
Aaaaah I would love to! Expect a PR tonight! 馃尮