@wordpress/hooks
Advanced tools
Comparing version 1.1.8 to 1.2.0
@@ -25,6 +25,13 @@ import validateHookName from './validateHookName.js'; | ||
var handlers = void 0; | ||
if (hooks[hookName]) { | ||
handlers = hooks[hookName].handlers; | ||
if (!hooks[hookName]) { | ||
hooks[hookName] = { | ||
handlers: [], | ||
runs: 0 | ||
}; | ||
} | ||
hooks[hookName].runs++; | ||
handlers = hooks[hookName].handlers; | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
@@ -51,3 +58,2 @@ args[_key - 1] = arguments[_key]; | ||
} | ||
hooks[hookName].runs++; | ||
@@ -54,0 +60,0 @@ while (hookInfo.currentIndex < handlers.length) { |
@@ -35,6 +35,13 @@ 'use strict'; | ||
var handlers = void 0; | ||
if (hooks[hookName]) { | ||
handlers = hooks[hookName].handlers; | ||
if (!hooks[hookName]) { | ||
hooks[hookName] = { | ||
handlers: [], | ||
runs: 0 | ||
}; | ||
} | ||
hooks[hookName].runs++; | ||
handlers = hooks[hookName].handlers; | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
@@ -61,3 +68,2 @@ args[_key - 1] = arguments[_key]; | ||
} | ||
hooks[hookName].runs++; | ||
@@ -64,0 +70,0 @@ while (hookInfo.currentIndex < handlers.length) { |
{ | ||
"name": "@wordpress/hooks", | ||
"version": "1.1.8", | ||
"version": "1.2.0", | ||
"description": "WordPress Hooks library", | ||
@@ -5,0 +5,0 @@ "author": "WordPress", |
@@ -25,6 +25,13 @@ import validateHookName from './validateHookName.js'; | ||
let handlers; | ||
if ( hooks[ hookName ] ) { | ||
handlers = hooks[ hookName ].handlers; | ||
if ( ! hooks[ hookName ] ) { | ||
hooks[ hookName ] = { | ||
handlers: [], | ||
runs: 0, | ||
}; | ||
} | ||
hooks[ hookName ].runs++; | ||
handlers = hooks[ hookName ].handlers; | ||
if ( ! handlers || ! handlers.length ) { | ||
@@ -49,3 +56,2 @@ return returnFirstArg | ||
} | ||
hooks[ hookName ].runs++; | ||
@@ -52,0 +58,0 @@ while ( hookInfo.currentIndex < handlers.length ) { |
@@ -497,2 +497,12 @@ /* eslint-disable no-console */ | ||
// Verify an action with no handlers is still counted | ||
expect( didAction( 'unattached.action' ) ).toBe( 0 ); | ||
doAction( 'unattached.action' ); | ||
expect( doingAction( 'unattached.action' ) ).toBe( false ); | ||
expect( didAction( 'unattached.action' ) ).toBe( 1 ); | ||
doAction( 'unattached.action' ); | ||
expect( doingAction( 'unattached.action' ) ).toBe( false ); | ||
expect( didAction( 'unattached.action' ) ).toBe( 2 ); | ||
// Verify hasAction returns 0 when no matching action. | ||
@@ -499,0 +509,0 @@ expect( hasAction( 'notatest.action' ) ).toBe( false ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70528
1892
1