Skip to content

Commit

Permalink
Merge pull request #12 from webKrafters/patch
Browse files Browse the repository at this point in the history
a tag-only change payload case
  • Loading branch information
steveswork authored Jun 7, 2024
2 parents a15c5e4 + a3411d6 commit bd97c06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@
"test:watch": "jest --updateSnapshot --watchAll"
},
"types": "dist/index.d.ts",
"version": "1.0.1"
"version": "1.0.2-rc.0"
}
34 changes: 21 additions & 13 deletions src/model/accessor-cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type {
AccessorPayload,
AccessorResponse,
Changes,
UpdatePayload,
UpdatePayloadArray,
UpdatePayloadArrayCore,
UpdatePayloadArrayCoreCloneable,
UpdatePayloadCore,
UpdatePayloadCoreCloneable,
Value
import {
Tag,
TagType,
type AccessorPayload,
type AccessorResponse,
type Changes,
type UpdatePayload,
type UpdatePayloadArray,
type UpdatePayloadArrayCore,
type UpdatePayloadArrayCoreCloneable,
type UpdatePayloadCore,
type UpdatePayloadCoreCloneable,
type Value
} from '../..';

interface PropertyOriginInfo {
Expand Down Expand Up @@ -52,18 +54,24 @@ class AccessorCache<T extends Value> {
const accessors = this.#accessors;
const atoms = this.#atoms;
const updatedPaths = [];
let tags : Array<TagType>;
for( const path in atoms ) {
const { exists, value: newAtomVal } = this.#getOriginAt( path );
if( path !== GLOBAL_SELECTOR && exists && (
newAtomVal === null || newAtomVal === undefined
) ) {
if( !tags ) { tags = Object.values( Tag ) }
/* istanbul ignore next */
if( !Array.isArray( originChanges ) ) {
if( !getProperty( originChanges, path ).trail.length ) { continue }
if( !getProperty( originChanges, path ).trail.length
&& !tags.some( tag => tag in originChanges )
) { continue }
} else {
let found = false;
for( let i = originChanges.length; i--; ) {
if( getProperty( originChanges, `${ i }.${ path }` ).trail.length ) {
if( getProperty( originChanges, `${ i }.${ path }` ).trail.length
|| tags.some( tag => tag in originChanges[ i ] )
) {
found = true;
break;
}
Expand Down

0 comments on commit bd97c06

Please sign in to comment.