mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #10019 from Snuffleupagus/eventBusDispatchToDOM
Add general support for re-dispatching events, on `EventBus` instances, to the DOM
This commit is contained in:
commit
f2f2e05bb8
9 changed files with 113 additions and 22 deletions
|
@ -262,6 +262,45 @@ describe('ui_utils', function() {
|
|||
eventBus.dispatch('test');
|
||||
expect(count).toEqual(2);
|
||||
});
|
||||
|
||||
it('should not, by default, re-dispatch to DOM', function(done) {
|
||||
if (isNodeJS()) {
|
||||
pending('Document in not supported in Node.js.');
|
||||
}
|
||||
const eventBus = new EventBus();
|
||||
let count = 0;
|
||||
eventBus.on('test', function() {
|
||||
count++;
|
||||
});
|
||||
document.addEventListener('test', function() {
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch('test');
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
expect(count).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should re-dispatch to DOM', function(done) {
|
||||
if (isNodeJS()) {
|
||||
pending('Document in not supported in Node.js.');
|
||||
}
|
||||
const eventBus = new EventBus({ dispatchToDOM: true, });
|
||||
let count = 0;
|
||||
eventBus.on('test', function() {
|
||||
count++;
|
||||
});
|
||||
document.addEventListener('test', function() {
|
||||
count++;
|
||||
});
|
||||
eventBus.dispatch('test');
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
expect(count).toEqual(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isValidRotation', function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue