@wordpress/interactivity
Advanced tools
Comparing version 6.8.4 to 6.8.5
@@ -271,3 +271,4 @@ /** | ||
if (propSignal) { | ||
propSignal.setValue(target[key]); | ||
const ns = getNamespaceFromProxy(proxy); | ||
propSignal.setValue(proxifyState(ns, target[key])); | ||
} | ||
@@ -281,3 +282,7 @@ } | ||
if (propSignal) { | ||
propSignal.setValue(desc.value); | ||
const { | ||
value | ||
} = desc; | ||
const ns = getNamespaceFromProxy(proxy); | ||
propSignal.setValue(shouldProxy(value) ? proxifyState(ns, value) : value); | ||
} | ||
@@ -284,0 +289,0 @@ } |
@@ -280,3 +280,4 @@ "use strict"; | ||
if (propSignal) { | ||
propSignal.setValue(target[key]); | ||
const ns = (0, _registry.getNamespaceFromProxy)(proxy); | ||
propSignal.setValue(proxifyState(ns, target[key])); | ||
} | ||
@@ -290,3 +291,7 @@ } | ||
if (propSignal) { | ||
propSignal.setValue(desc.value); | ||
const { | ||
value | ||
} = desc; | ||
const ns = (0, _registry.getNamespaceFromProxy)(proxy); | ||
propSignal.setValue((0, _registry.shouldProxy)(value) ? proxifyState(ns, value) : value); | ||
} | ||
@@ -293,0 +298,0 @@ } |
@@ -7,5 +7,17 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
- Fix reactivity of undefined objects and arrays added with `deepMerge()` ([#66183](https://github.com/WordPress/gutenberg/pull/66183)). | ||
## 6.10.0 (2024-10-16) | ||
### Internal | ||
- Upgrade preact libraries [#66008](https://github.com/WordPress/gutenberg/pull/66008). | ||
### Bug Fixes | ||
- Fix an issue where "default" could not be used as a directive suffix ([#65815](https://github.com/WordPress/gutenberg/pull/65815)). | ||
- Correctly handle lazily added, deeply nested properties with `deepMerge()` ([#65465](https://github.com/WordPress/gutenberg/pull/65465)). | ||
## 6.9.0 (2024-10-03) | ||
## 6.8.0 (2024-09-19) | ||
@@ -12,0 +24,0 @@ |
{ | ||
"name": "@wordpress/interactivity", | ||
"version": "6.8.4", | ||
"version": "6.8.5", | ||
"description": "Package that provides a standard and simple way to handle the frontend interactivity of Gutenberg blocks.", | ||
@@ -40,3 +40,3 @@ "author": "The WordPress Contributors", | ||
}, | ||
"gitHead": "b7af02f8431034ee19cdc33dd105d21705823eed" | ||
"gitHead": "b1ace05ee94f0803e51b205306c19fc706499ede" | ||
} |
@@ -338,3 +338,6 @@ /** | ||
if ( propSignal ) { | ||
propSignal.setValue( target[ key ] ); | ||
const ns = getNamespaceFromProxy( proxy ); | ||
propSignal.setValue( | ||
proxifyState( ns, target[ key ] as Object ) | ||
); | ||
} | ||
@@ -348,3 +351,7 @@ } | ||
if ( propSignal ) { | ||
propSignal.setValue( desc.value ); | ||
const { value } = desc; | ||
const ns = getNamespaceFromProxy( proxy ); | ||
propSignal.setValue( | ||
shouldProxy( value ) ? proxifyState( ns, value ) : value | ||
); | ||
} | ||
@@ -351,0 +358,0 @@ } |
@@ -382,3 +382,6 @@ /* eslint-disable eslint-comments/disable-enable-pair */ | ||
const spy = jest.fn( () => Object.keys( target ) ); | ||
let keys: any; | ||
const spy = jest.fn( () => { | ||
keys = Object.keys( target ); | ||
} ); | ||
effect( spy ); | ||
@@ -391,3 +394,3 @@ | ||
expect( spy ).toHaveBeenCalledTimes( 2 ); | ||
expect( spy ).toHaveLastReturnedWith( [ 'a', 'b', 'c' ] ); | ||
expect( keys ).toEqual( [ 'a', 'b', 'c' ] ); | ||
} ); | ||
@@ -417,2 +420,9 @@ | ||
expect( target.a.b.c.d ).toBe( 'test value' ); | ||
// Modify the nested value | ||
target.a.b.c.d = 'new test value'; | ||
// The effect should be called again | ||
expect( spy ).toHaveBeenCalledTimes( 3 ); | ||
expect( deepValue ).toBe( 'new test value' ); | ||
} ); | ||
@@ -468,3 +478,31 @@ | ||
} ); | ||
it( 'should keep reactivity of arrays that are initially undefined', () => { | ||
const target: any = proxifyState( 'test', {} ); | ||
let deepValue: any; | ||
const spy = jest.fn( () => { | ||
deepValue = target.array?.[ 0 ]; | ||
} ); | ||
effect( spy ); | ||
// Initial call, the deep value is undefined | ||
expect( spy ).toHaveBeenCalledTimes( 1 ); | ||
expect( deepValue ).toBeUndefined(); | ||
// Use deepMerge to add an array to the target | ||
deepMerge( target, { array: [ 'value 1' ] } ); | ||
// The effect should be called again | ||
expect( spy ).toHaveBeenCalledTimes( 2 ); | ||
expect( deepValue ).toBe( 'value 1' ); | ||
// Modify the array value | ||
target.array[ 0 ] = 'value 2'; | ||
// The effect should be called again | ||
expect( spy ).toHaveBeenCalledTimes( 3 ); | ||
expect( deepValue ).toBe( 'value 2' ); | ||
} ); | ||
} ); | ||
} ); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
704170
10136