mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Use private fields in a few more viewer classes
These properties were always intended to be *private*, so let's use modern JS features to actually enforce that.
This commit is contained in:
parent
eda51d1dcc
commit
e7a6e7393a
3 changed files with 12 additions and 18 deletions
|
@ -75,9 +75,7 @@ function waitOnEventOrTimeout({ target, name, delay = 0 }) {
|
|||
* and `off` methods. To raise an event, the `dispatch` method shall be used.
|
||||
*/
|
||||
class EventBus {
|
||||
constructor() {
|
||||
this._listeners = Object.create(null);
|
||||
}
|
||||
#listeners = Object.create(null);
|
||||
|
||||
/**
|
||||
* @param {string} eventName
|
||||
|
@ -108,7 +106,7 @@ class EventBus {
|
|||
* @param {Object} data
|
||||
*/
|
||||
dispatch(eventName, data) {
|
||||
const eventListeners = this._listeners[eventName];
|
||||
const eventListeners = this.#listeners[eventName];
|
||||
if (!eventListeners || eventListeners.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -139,7 +137,7 @@ class EventBus {
|
|||
* @ignore
|
||||
*/
|
||||
_on(eventName, listener, options = null) {
|
||||
const eventListeners = (this._listeners[eventName] ||= []);
|
||||
const eventListeners = (this.#listeners[eventName] ||= []);
|
||||
eventListeners.push({
|
||||
listener,
|
||||
external: options?.external === true,
|
||||
|
@ -151,7 +149,7 @@ class EventBus {
|
|||
* @ignore
|
||||
*/
|
||||
_off(eventName, listener, options = null) {
|
||||
const eventListeners = this._listeners[eventName];
|
||||
const eventListeners = this.#listeners[eventName];
|
||||
if (!eventListeners) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue