1
1
/**
2
2
* Inter.
3
- * Version: 1.2.8
3
+ * Version: 1.2.9
4
4
* 2021 - 2022 - by Denis Power.
5
5
* https://github.com/interjs/inter
6
6
* A Javascript framework to build interactive frontend applications.
@@ -106,6 +106,7 @@ function isInput(target){
106
106
107
107
}
108
108
109
+
109
110
const Dev = {
110
111
111
112
get status ( ) {
@@ -571,7 +572,7 @@ let _status="development"
571
572
const app = {
572
573
get version ( ) {
573
574
574
- return "1.2.8 "
575
+ return "1.2.9 "
575
576
576
577
} ,
577
578
@@ -2955,12 +2956,12 @@ let newREF={
2955
2956
2956
2957
2957
2958
if ( root . length > 0 && target . length > 0 ) {
2958
- for ( let el = target . length - 1 ; el > - 1 ; el -- ) {
2959
+ for ( let index = 0 ; index < target . length - 1 ; index ++ ) {
2959
2960
2960
2961
2961
- if ( notSameTagName ( target [ el ] , root [ el ] ) ) {
2962
+ if ( notSameTagName ( target [ index ] , root [ index ] ) ) {
2962
2963
2963
- root [ el ] . parentNode . replaceChild ( target [ el ] , root [ el ] ) ;
2964
+ root [ index ] . parentNode . replaceChild ( target [ index ] , root [ index ] ) ;
2964
2965
2965
2966
continue ;
2966
2967
@@ -2969,13 +2970,11 @@ let newREF={
2969
2970
2970
2971
2971
2972
2972
- if ( isDefined ( root [ el ] ) && isDefined ( target [ el ] ) &&
2973
- deeplyNotIqualElements ( root [ el ] , target [ el ] ) ) {
2974
-
2975
-
2976
- root [ el ] . parentNode . replaceChild ( target [ el ] , root [ el ] )
2977
-
2973
+ if ( isDefined ( root [ index ] ) && isDefined ( target [ index ] ) &&
2974
+ deeplyNotEqualElements ( root [ index ] , target [ index ] ) ) {
2978
2975
2976
+ root [ index ] . parentNode . replaceChild ( target [ index ] , root [ index ] )
2977
+
2979
2978
2980
2979
2981
2980
@@ -3000,7 +2999,7 @@ let newREF={
3000
2999
3001
3000
// There is no parent elements.
3002
3001
3003
- if ( deeplyNotIqualElements ( value , father ) ) {
3002
+ if ( deeplyNotEqualElements ( value , father ) ) {
3004
3003
3005
3004
parent . replaceChild ( value , father ) ;
3006
3005
@@ -3030,7 +3029,7 @@ let newREF={
3030
3029
3031
3030
}
3032
3031
3033
- function deeplyNotIqualElements ( target , toCompare ) {
3032
+ function deeplyNotEqualElements ( target , toCompare ) {
3034
3033
3035
3034
3036
3035
@@ -3268,6 +3267,7 @@ definePro(Inter, "for", (obj)=>{
3268
3267
3269
3268
3270
3269
let pro = null ;
3270
+ const cond = new Set ( ) ;
3271
3271
3272
3272
if ( isArray ( data ) ) {
3273
3273
@@ -3501,45 +3501,29 @@ Warning("do in Inter.for() must be a function");
3501
3501
3502
3502
data . forEach ( ( item , i ) => {
3503
3503
var value = DO . call ( pro , item , i ) ;
3504
-
3505
- if ( ! isaNodeElement ( value ) ) {
3504
+
3505
+ if ( ! isaNodeElement ( value ) ) {
3506
+
3507
+
3506
3508
3507
3509
SyntaxErr ( `
3508
3510
You are not returning the template()
3509
3511
function in do() method(Inter.for). It is happening where the target id is "${ IN } ".
3510
3512
3511
- If you are returning the template function, this error is being thrown because
3512
- you are creating more than one element without a container. When you create
3513
- more than one element with the template function put the created element inside a container.
3514
- like:
3515
-
3516
- template({
3517
-
3518
- elements:[{
3519
-
3520
- tag:"div", children:[{
3521
- tag:"h2", text:"user"
3522
- },{
3523
-
3524
- tag:"p", text:"The user's description."
3525
-
3526
- }]
3527
-
3528
- }]
3529
-
3530
- })
3531
3513
3532
3514
` )
3533
3515
3534
3516
}
3535
-
3517
+
3518
+
3536
3519
for ( let el of value ) {
3537
3520
3538
3521
3539
3522
root . appendChild ( el ) ;
3540
3523
}
3541
3524
3542
3525
3526
+
3543
3527
} )
3544
3528
someRef . add ( IN ) ;
3545
3529
return false ;
@@ -3551,28 +3535,41 @@ Warning("do in Inter.for() must be a function");
3551
3535
3552
3536
let _value = DO . call ( pro , el , i ) ;
3553
3537
3538
+
3554
3539
3540
+ if ( ! isaNodeElement ( _value ) ) {
3541
+
3542
+ SyntaxErr ( `
3543
+ You are not returning the template()
3544
+ function in do() method(Inter.for). It is happening where the target id is "${ IN } ".
3545
+
3546
+
3547
+ ` )
3548
+
3549
+ }
3555
3550
3556
3551
3557
- if ( isDefined ( root . children [ i ] ) ) {
3552
+ else if ( isDefined ( root . children [ i ] ) ) {
3558
3553
3559
3554
for ( let _el of _value ) {
3560
3555
3561
- calculateUpdate ( _el , root , i )
3556
+ calculateUpdate ( _el , root , i )
3562
3557
}
3563
- }
3564
- if ( ! isDefined ( root . children [ i ] ) ) {
3558
+ } else {
3559
+ if ( ! isDefined ( root . children [ i ] ) ) {
3565
3560
3566
- if ( data . length > root . children . length ) {
3561
+ if ( data . length - cond . size > root . children . length ) {
3567
3562
for ( v of _value ) {
3568
3563
3569
3564
3570
3565
root . appendChild ( v )
3571
-
3566
+ return ;
3572
3567
}
3568
+
3569
+
3573
3570
}
3574
3571
}
3575
-
3572
+ }
3576
3573
} )
3577
3574
3578
3575
@@ -5004,6 +5001,28 @@ const{
5004
5001
5005
5002
}
5006
5003
5004
+ if ( elements . length > 1 ) {
5005
+
5006
+ consoleWarnig ( `
5007
+
5008
+ You are creating more than one element without a container in template function,
5009
+ put the created element inside a container like:
5010
+
5011
+ template({
5012
+ elements:[{
5013
+ //container.
5014
+ tag:"div", children:[{
5015
+
5016
+ //The elements here!
5017
+
5018
+ }]
5019
+ }]
5020
+ })
5021
+
5022
+ ` )
5023
+
5024
+ }
5025
+
5007
5026
let returnELS = array . create ( null ) ;
5008
5027
5009
5028
@@ -5023,7 +5042,11 @@ const{
5023
5042
5024
5043
if ( tag == void 0 ) {
5025
5044
5026
- return ;
5045
+ SyntaxErr ( `
5046
+
5047
+ You can not render a container conditionally, in template function.
5048
+
5049
+ ` )
5027
5050
5028
5051
}
5029
5052
@@ -5160,13 +5183,13 @@ const{
5160
5183
5161
5184
}
5162
5185
5163
-
5186
+
5164
5187
5165
5188
returnELS . push ( container )
5166
5189
5167
5190
5168
5191
5169
-
5192
+
5170
5193
5171
5194
5172
5195
return returnELS ;
0 commit comments