-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: provide default no-op implementation for events
BREAKING CHANGE: By default parsers now have a default no-op implementation for each event it supports. This would break code that determines whether a custom handler was added by checking whether there's any handler at all. This removes the necessity for the parser implementation to check whether there is a handler before calling it. In the process of making this change, we've removed support for the ``on...`` properties on streams objects. Their existence was not warranted by any standard API provided by Node. (``EventEmitter`` does not have ``on...`` properties for events it supports, nor does ``Stream``.) Their existence was also undocumented. And their functioning was awkward. For instance, with sax, this: ``` const s = sax.createStream(); const handler = () => console.log("moo"); s.on("cdata", handler); console.log(s.oncdata === handler); ``` would print ``false``. If you examine ``s.oncdata`` you see it is glue code instead of the handler assigned. This is just bizarre, so we removed it.
- Loading branch information
Showing
1 changed file
with
35 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters