File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,7 +330,7 @@ export function stripDeepObjectPrototype<T>(unk: T): T {
330330
331331 // @ts -expect-error in 2026, typescript doesn't know yet
332332 for ( const value of unk ) {
333- rv . push ( stripDeepObjectPrototype ( value ) ) ;
333+ rv . push ( stripDeepObjectPrototype ( value ) ) ; // recursion
334334 }
335335
336336 return < T > rv ;
@@ -341,7 +341,7 @@ export function stripDeepObjectPrototype<T>(unk: T): T {
341341 const obj = < ISerializableObject > unk ;
342342
343343 for ( const key of Reflect . ownKeys ( obj ) ) {
344- rv [ key ] = stripDeepObjectPrototype ( obj [ key ] ) ;
344+ rv [ key ] = stripDeepObjectPrototype ( obj [ key ] ) ; // recursion
345345 }
346346
347347 return < T > rv ;
Original file line number Diff line number Diff line change 11import { hasValue } from './toolkit.ts' ;
2- import { type ISerializableObject , stripDeepObjectPrototype } from './clone.ts' ;
2+ import { type ISerializableObject } from './clone.ts' ;
33import { create , type Delta } from 'jsondiffpatch/with-text-diffs' ;
44import { format as formatHtml } from 'jsondiffpatch/formatters/html' ;
55import { format as formatRFC6902 } from 'jsondiffpatch/formatters/jsonpatch' ;
@@ -54,10 +54,7 @@ export function buildDeltaElement(
5454 let html : string | undefined ;
5555
5656 try {
57- html = formatHtml (
58- stripDeepObjectPrototype ( delta ) ,
59- stripDeepObjectPrototype ( left ) ,
60- ) ;
57+ html = formatHtml ( delta , left ) ;
6158 html = DOMPurify . sanitize ( html || '' ) ;
6259 } catch ( e ) {
6360 console . error ( 'buildDeltaElement' , e ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ function defaultCompareState(): ICompareState {
2121 } ;
2222}
2323
24+ function castrateObject < T > ( that : T ) : T {
25+ if ( that !== null && typeof that === 'object' ) {
26+ return markRaw ( Object . freeze ( stripDeepObjectPrototype ( that ) ) ) ;
27+ }
28+
29+ return that ;
30+ }
31+
2432export const useCompareStore = defineStore ( 'compareStore' , {
2533 state : ( ) => ( {
2634 initialized : false ,
@@ -38,20 +46,15 @@ export const useCompareStore = defineStore('compareStore', {
3846 } ,
3947
4048 deltaObj ( ) : Delta {
41- return diff (
42- stripDeepObjectPrototype ( this . compare . left ) ,
43- stripDeepObjectPrototype ( this . compare . right ) ,
44- ) ;
49+ return castrateObject ( diff ( this . compare . left , this . compare . right ) ) ;
4550 } ,
4651 } ,
4752
4853 actions : {
4954 assign ( { left, right, timestamp } : ICompareState ) {
5055 this . compare = {
51- left : left !== null && typeof left === 'object' ? markRaw ( left ) : left ,
52- right : right !== null && typeof right === 'object'
53- ? markRaw ( right )
54- : right ,
56+ left : castrateObject ( left ) ,
57+ right : castrateObject ( right ) ,
5558 timestamp : timestamp || Date . now ( ) ,
5659 } ;
5760 } ,
You can’t perform that action at this time.
0 commit comments