Socket
Socket
Sign inDemoInstall

@wordpress/hooks

Package Overview
Dependencies
Maintainers
5
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/hooks - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

CHANGELOG.md

7

build-module/createRunHook.js

@@ -54,3 +54,8 @@ import validateHookName from './validateHookName.js';

var handler = handlers[hookInfo.currentIndex];
args[0] = handler.callback.apply(null, args);
var result = handler.callback.apply(null, args);
if (returnFirstArg) {
args[0] = result;
}
hookInfo.currentIndex++;

@@ -57,0 +62,0 @@ }

@@ -64,3 +64,8 @@ 'use strict';

var handler = handlers[hookInfo.currentIndex];
args[0] = handler.callback.apply(null, args);
var result = handler.callback.apply(null, args);
if (returnFirstArg) {
args[0] = result;
}
hookInfo.currentIndex++;

@@ -67,0 +72,0 @@ }

2

package.json
{
"name": "@wordpress/hooks",
"version": "1.1.5",
"version": "1.1.6",
"description": "WordPress Hooks library",

@@ -5,0 +5,0 @@ "author": "WordPress",

@@ -52,3 +52,8 @@ import validateHookName from './validateHookName.js';

const handler = handlers[ hookInfo.currentIndex ];
args[ 0 ] = handler.callback.apply( null, args );
const result = handler.callback.apply( null, args );
if ( returnFirstArg ) {
args[ 0 ] = result;
}
hookInfo.currentIndex++;

@@ -55,0 +60,0 @@ }

@@ -575,2 +575,28 @@ /* eslint-disable no-console */

test( 'actions preserve arguments across handlers without return value', () => {
const arg1 = { a: 10 };
const arg2 = { b: 20 };
addAction( 'test.action', 'my_callback1', ( a, b ) => {
expect( a ).toBe( arg1 );
expect( b ).toBe( arg2 );
} );
addAction( 'test.action', 'my_callback2', ( a, b ) => {
expect( a ).toBe( arg1 );
expect( b ).toBe( arg2 );
} );
doAction( 'test.action', arg1, arg2 );
} );
test( 'filters pass first argument across handlers', () => {
addFilter( 'test.filter', 'my_callback1', ( count ) => count + 1 );
addFilter( 'test.filter', 'my_callback2', ( count ) => count + 1 );
const result = applyFilters( 'test.filter', 0 );
expect( result ).toBe( 2 );
} );
// Test adding via composition.

@@ -577,0 +603,0 @@ test( 'adding hooks via composition', () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc