Skip to content

Commit 5851151

Browse files
authored
Merge pull request #55 from interjs/progress
Progress
2 parents 0e91f94 + 8dba6b1 commit 5851151

File tree

5 files changed

+152
-107
lines changed

5 files changed

+152
-107
lines changed

inter.js

Lines changed: 69 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Inter.
3-
* Version: 1.2.8
3+
* Version: 1.2.9
44
* 2021 - 2022 - by Denis Power.
55
* https://github.com/interjs/inter
66
* A Javascript framework to build interactive frontend applications.
@@ -106,6 +106,7 @@ function isInput(target){
106106

107107
}
108108

109+
109110
const Dev={
110111

111112
get status(){
@@ -571,7 +572,7 @@ let _status="development"
571572
const app={
572573
get version(){
573574

574-
return "1.2.8"
575+
return "1.2.9"
575576

576577
},
577578

@@ -2955,12 +2956,12 @@ let newREF={
29552956

29562957

29572958
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++){
29592960

29602961

2961-
if(notSameTagName(target[el], root[el])){
2962+
if(notSameTagName(target[index], root[index])){
29622963

2963-
root[el].parentNode.replaceChild(target[el], root[el]);
2964+
root[index].parentNode.replaceChild(target[index], root[index]);
29642965

29652966
continue;
29662967

@@ -2969,13 +2970,11 @@ let newREF={
29692970

29702971

29712972

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]) ){
29782975

2976+
root[index].parentNode.replaceChild(target[index],root[index])
2977+
29792978

29802979

29812980

@@ -3000,7 +2999,7 @@ let newREF={
30002999

30013000
// There is no parent elements.
30023001

3003-
if(deeplyNotIqualElements(value, father)){
3002+
if(deeplyNotEqualElements(value, father)){
30043003

30053004
parent.replaceChild(value, father);
30063005

@@ -3030,7 +3029,7 @@ let newREF={
30303029

30313030
}
30323031

3033-
function deeplyNotIqualElements(target,toCompare){
3032+
function deeplyNotEqualElements(target,toCompare){
30343033

30353034

30363035

@@ -3268,6 +3267,7 @@ definePro(Inter, "for", (obj)=>{
32683267

32693268

32703269
let pro=null;
3270+
const cond=new Set();
32713271

32723272
if(isArray(data)){
32733273

@@ -3501,45 +3501,29 @@ Warning("do in Inter.for() must be a function");
35013501

35023502
data.forEach((item, i)=>{
35033503
var value=DO.call(pro,item, i);
3504-
3505-
if(!isaNodeElement(value)){
3504+
3505+
if(!isaNodeElement(value) ){
3506+
3507+
35063508

35073509
SyntaxErr(`
35083510
You are not returning the template()
35093511
function in do() method(Inter.for). It is happening where the target id is "${IN}".
35103512
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-
})
35313513
35323514
`)
35333515

35343516
}
3535-
3517+
3518+
35363519
for(let el of value){
35373520

35383521

35393522
root.appendChild(el);
35403523
}
35413524

35423525

3526+
35433527
})
35443528
someRef.add(IN);
35453529
return false;
@@ -3551,28 +3535,41 @@ Warning("do in Inter.for() must be a function");
35513535

35523536
let _value=DO.call(pro,el,i);
35533537

3538+
35543539

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+
}
35553550

35563551

3557-
if(isDefined(root.children[i])){
3552+
else if(isDefined(root.children[i])){
35583553

35593554
for(let _el of _value){
35603555

3561-
calculateUpdate(_el,root,i)
3556+
calculateUpdate(_el,root, i)
35623557
}
3563-
}
3564-
if(!isDefined(root.children[i])){
3558+
}else{
3559+
if(!isDefined(root.children[i])){
35653560

3566-
if(data.length>root.children.length){
3561+
if(data.length-cond.size>root.children.length){
35673562
for( v of _value){
35683563

35693564

35703565
root.appendChild(v)
3571-
3566+
return;
35723567
}
3568+
3569+
35733570
}
35743571
}
3575-
3572+
}
35763573
})
35773574

35783575

@@ -5004,6 +5001,28 @@ const{
50045001

50055002
}
50065003

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+
50075026
let returnELS=array.create(null);
50085027

50095028

@@ -5023,7 +5042,11 @@ const{
50235042

50245043
if(tag==void 0){
50255044

5026-
return;
5045+
SyntaxErr(`
5046+
5047+
You can not render a container conditionally, in template function.
5048+
5049+
`)
50275050

50285051
}
50295052

@@ -5160,13 +5183,13 @@ const{
51605183

51615184
}
51625185

5163-
5186+
51645187

51655188
returnELS.push(container)
51665189

51675190

51685191

5169-
5192+
51705193

51715194

51725195
return returnELS;

inter.min.js

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)