Skip to content

Commit

Permalink
fix: no need to pass in empty Set in deprecated hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Jun 15, 2022
1 parent c7fa73b commit 3a015eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/plugins/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@ Hooks._deprecated = new Map([
new: 'static:email.send',
since: 'v1.17.0',
until: 'v2.0.0',
affected: new Set(),
}],
['filter:router.page', {
new: 'response:router.page',
since: 'v1.15.3',
until: 'v2.1.0',
affected: new Set(),
}],
['filter:post.purge', {
new: 'filter:posts.purge',
since: 'v1.19.6',
until: 'v2.1.0',
affected: new Set(),
}],
['action:post.purge', {
new: 'action:posts.purge',
since: 'v1.19.6',
until: 'v2.1.0',
affected: new Set(),
}],
]);

Expand Down Expand Up @@ -63,6 +59,9 @@ Hooks.register = function (id, data) {
// `hasOwnProperty` needed for hooks with no alternative (set to null)
if (Hooks._deprecated.has(data.hook)) {
const deprecation = Hooks._deprecated.get(data.hook);
if (!deprecation.hasOwnProperty('affected')) {
deprecation.affected = new Set();
}
deprecation.affected.add(id);
Hooks._deprecated.set(data.hook, deprecation);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Plugins.reload = async function () {

// Deprecation notices
Plugins.hooks._deprecated.forEach((deprecation, hook) => {
if (!deprecation.affected.size) {
if (!deprecation.affected || !deprecation.affected.size) {
return;
}

Expand Down

0 comments on commit 3a015eb

Please sign in to comment.