This repository was archived by the owner on May 19, 2023. It is now read-only.
File tree 3 files changed +18
-4
lines changed
3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { KV } from '@models/generics' ;
2
2
import { State , Watchers } from '@models/structs' ;
3
+ import { error } from '@utils/log' ;
3
4
4
5
export const arrayEquals = ( firstArray : unknown [ ] , secondArray : unknown [ ] ) : boolean => {
5
6
// Deep Array equality check
@@ -16,13 +17,19 @@ export const reactive = (
16
17
render : ( props : string [ ] ) => void ,
17
18
watchers : Watchers = { }
18
19
) : State => {
20
+ const supportedObjectTypes = [ 'Object' , 'Array' ] . map ( ( type : string ) => `[object ${ type } ]` ) ;
19
21
const handler = {
20
22
get ( target : KV < unknown > , key : string ) : unknown {
21
23
const ret = target [ key ] ;
22
-
23
24
if ( typeof ret === 'object' && ret !== null ) {
24
- // Deep proxy - if there is an object in an object, need to proxify that.
25
- return new Proxy ( ret , handler ) ;
25
+ const objectType = Object . prototype . toString . call ( ret ) ;
26
+ if ( supportedObjectTypes . includes ( objectType ) ) {
27
+ // Deep proxy - if there is an object in an object, need to proxify that.
28
+ return new Proxy ( ret as KV < unknown > , handler ) ;
29
+ } else {
30
+ error ( `Data type ${ objectType } is not supported` ) ;
31
+ return ret ;
32
+ }
26
33
} else {
27
34
return ret ;
28
35
}
Original file line number Diff line number Diff line change 1
1
import { KV } from '@models/generics' ;
2
2
import { Refs } from '@models/structs' ;
3
+ import { error } from '@utils/log' ;
3
4
4
5
export const computeExpression = (
5
6
expression : string ,
@@ -48,7 +49,7 @@ export const computeExpression = (
48
49
) ;
49
50
}
50
51
} catch ( err ) {
51
- console . warn ( `Lucia Error: " ${ err } "\n\nExpression: " ${ expression } "\nElement:` , el ) ;
52
+ error ( err , expression , el ) ;
52
53
}
53
54
} ;
54
55
} ;
Original file line number Diff line number Diff line change
1
+ export const error = ( err : string , expression ?: string , el ?: HTMLElement ) : void => {
2
+ let message = `Lucia Error: "${ err } "` ;
3
+ if ( expression ) message += `\n\nExpression: "${ expression } "` ;
4
+ if ( el ) message += `\nElement:` ;
5
+ console . warn ( message , el ) ;
6
+ } ;
You can’t perform that action at this time.
0 commit comments