@@ -829,7 +829,7 @@ simply = {
829
829
this . dom = dom ;
830
830
this . lifecycle = lifecycle ;
831
831
832
- this . propsToObserve = props ;
832
+ this . props = props ;
833
833
834
834
this . dataToObserve = data ;
835
835
this . data ;
@@ -968,7 +968,7 @@ simply = {
968
968
mutations . forEach ( function ( mutation ) {
969
969
if ( mutation . type === 'attributes' ) {
970
970
var newVal = mutation . target . getAttribute ( mutation . attributeName ) ;
971
- // console.log(mutation.attributeName, "attribute changed to", newVal);
971
+ console . log ( mutation . attributeName , "attribute changed to" , newVal ) ;
972
972
callback ( mutation . attributeName , newVal ) ;
973
973
974
974
}
@@ -990,23 +990,27 @@ simply = {
990
990
}
991
991
connectedCallback ( ) {
992
992
this . observeAttrChange ( this , function ( name , newValue ) {
993
+ console . log ( "hee" ) ;
993
994
// value öncekiyle aynı değilse
994
995
// console.log(name, newValue, self.props[name], newValue == simply.prepareAttr(self.props[name]));
995
- if ( newValue !== simply . prepareAttr ( self . props [ name ] ) ) {
996
- try {
997
- newValue = simply . parseProp ( newValue ) . value ;
998
- } catch ( e ) {
999
- // getattribute parse edemezse
1000
- newValue = newValue ;
1001
- }
1002
-
1003
- self . props [ name ] = newValue ;
1004
- if ( typeof self . lifecycle !== "undefined" ) {
1005
- if ( typeof self . lifecycle . whenPropChange !== "undefined" ) {
1006
- console . log ( "propchange" ) ;
1007
- self . lifecycle . whenPropChange ( name , self . props [ name ] , newValue ) ;
996
+ if ( self . props [ name ] ) {
997
+ if ( newValue !== simply . prepareAttr ( self . props [ name ] ) ) {
998
+ try {
999
+ newValue = simply . parseProp ( newValue ) . value ;
1000
+ } catch ( e ) {
1001
+ // getattribute parse edemezse
1002
+ newValue = newValue ;
1003
+ }
1004
+
1005
+ self . props [ name ] = newValue ;
1006
+ if ( typeof self . lifecycle !== "undefined" ) {
1007
+ if ( typeof self . lifecycle . whenPropChange !== "undefined" ) {
1008
+ console . log ( "propchange" ) ;
1009
+ self . lifecycle . whenPropChange ( name , self . props [ name ] , newValue ) ;
1010
+ }
1008
1011
}
1009
- }
1012
+ }
1013
+
1010
1014
}
1011
1015
} ) ;
1012
1016
@@ -1075,33 +1079,77 @@ simply = {
1075
1079
}
1076
1080
}
1077
1081
1078
- if ( this . propsToObserve ) {
1079
- this . props = ObservableSlim . create ( this . propsToObserve , true , function ( changes ) {
1080
- for ( const [ key , cb ] of Object . entries ( self . cb . props ) ) {
1081
- if ( cb ) {
1082
- changes . forEach ( function ( change , key ) {
1083
- if ( change . newValue !== change . previousValue ) {
1084
- changes . forEach ( function ( change , key ) {
1085
- cb ( change . property , change . newValue , change . previousValue , true ) ;
1086
- } ) ;
1082
+ if ( this . props ) {
1083
+ let handler = {
1084
+ get : function ( obj , prop ) {
1085
+
1086
+ // props can contain only key: value not key: object
1087
+ // so no need to proxify child nodes
1088
+
1089
+ /*
1090
+ if (isObjectWithoutTriggeringGetter(obj, prop) ) {
1091
+ console.log(proxies, obj[prop], r);
1092
+ if (proxies.has(obj[prop])) {
1093
+ // console.log("uyy proxy daaa", obj[prop]);
1094
+ return proxies.get(obj[prop]);
1095
+ }
1096
+ else {
1097
+ // console.log("obje proxy'e dönüştürüldü", obj, prop);
1098
+ let proxy = new Proxy(obj[prop], handler);
1099
+ //proxies.add(proxy);
1100
+ proxies.set(obj[prop], proxy);
1101
+ return proxy;
1102
+ }
1103
+
1104
+ }
1105
+ else {
1106
+ //console.log("normal get", obj, prop);
1107
+ return obj[prop];
1108
+ }
1109
+ */
1110
+ return obj [ prop ] ;
1111
+ } ,
1112
+ set : function ( target , prop , value , receiver ) {
1113
+ if ( target [ prop ] !== value ) {
1114
+ Reflect . set ( ...arguments ) ;
1115
+ for ( const [ key , cb ] of Object . entries ( self . cb . props ) ) {
1116
+ if ( cb ) {
1117
+
1118
+ cb ( prop , value ) ;
1087
1119
}
1088
- } )
1120
+
1121
+ //console.log(`${key}: ${value}`);
1122
+ }
1123
+ }
1124
+ return true ; // Pass through the operation
1125
+ } ,
1126
+ deleteProperty : function ( target , prop ) {
1127
+ if ( prop in target ) {
1128
+ delete target [ prop ] ;
1129
+ //console.log(`property removed: ${prop}`);
1130
+ // Expected output: "property removed: texture"
1131
+ }
1132
+ for ( const [ key , cb ] of Object . entries ( self . cb . props ) ) {
1133
+ cb ( prop , null ) ;
1134
+ //console.log(`${key}: ${value}`);
1089
1135
}
1090
1136
}
1091
- } ) ;
1137
+ } ;
1092
1138
1093
1139
if ( template . indexOf ( "props." ) > - 1 || script . indexOf ( "props." ) > - 1 ) {
1094
1140
this . cb . props = { }
1095
- this . cb . props [ this . uid ] = function ( property , newValue , previousValue ) { self . react ( property , newValue , previousValue , true ) } ;
1141
+ this . cb . props [ this . uid ] = function ( prop , value ) { self . react ( prop , value , true ) } ;
1142
+ this . props = new Proxy ( this . props , handler ) ;
1096
1143
this . setProps ( this . props ) ;
1097
1144
this . setCbProps ( this . cb . props ) ;
1098
1145
}
1146
+
1099
1147
}
1100
1148
1101
1149
if ( this . stateToObserve ) {
1102
1150
if ( ! this . stateToObserve . __isProxy ) {
1103
1151
this . state = ObservableSlim . create ( this . stateToObserve , true , function ( changes ) {
1104
- console . log ( changes , templateName ) ;
1152
+ // console.log(changes, templateName);
1105
1153
if ( self . cb . state ) {
1106
1154
for ( const [ key , cb ] of Object . entries ( self . cb . state ) ) {
1107
1155
if ( cb ) {
@@ -1116,16 +1164,15 @@ simply = {
1116
1164
this . cb . state = { }
1117
1165
this . cb . state [ this . uid ] = function ( property , newValue , previousValue ) { self . react ( property , newValue , previousValue ) } ;
1118
1166
this . setCbState ( this . cb . state ) ;
1119
- console . log ( "bu bi kere çalışır" ) ;
1167
+ // console.log("bu bi kere çalışır");
1120
1168
// this.state = new Proxy(this.state, handler);
1121
1169
1122
1170
}
1123
1171
else {
1124
- console . log ( this . parent . state ) ;
1125
1172
this . state = this . parent . state
1126
1173
if ( template . indexOf ( "state." ) > - 1 || script . indexOf ( "state." ) > - 1 ) {
1127
1174
var p = findElementWithCB ( this . parent ) ;
1128
- console . log ( "ppp" , p , this . parent , templateName ) ;
1175
+ // console.log("ppp", p, this.parent, templateName);
1129
1176
p . cb . state [ this . uid ] = function ( property , newValue , previousValue ) { self . react ( property , newValue , previousValue ) } ;
1130
1177
// this.state = new Proxy(this.state, handler);
1131
1178
}
0 commit comments