Skip to content

Commit

Permalink
v2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisPower1 committed Aug 10, 2022
1 parent 3ca43a6 commit e0839d1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 89 deletions.
47 changes: 13 additions & 34 deletions core/renderif.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ function getChildNodes(root){

const nodes=new Array();

root.childNodes.forEach((node, index)=>{
root.childNodes.forEach((node)=>{

if(node.nodeType==1 || node.nodeType==3 && !node.textContent.trim().length==0){

if(node.index===void 0){

node.index=index;

};

nodes.push(node);

Expand Down Expand Up @@ -136,7 +130,7 @@ export function renderIf(obj){

let index=-1;

for(const child of container.children){
for(const child of container.childNodes){

index++;

Expand All @@ -151,6 +145,8 @@ export function renderIf(obj){

child.index=index;

if(child.nodeType==3)continue;


const sibling=child.nextElementSibling,
previous=child.previousElementSibling;
Expand Down Expand Up @@ -264,7 +260,6 @@ export function renderIf(obj){

} if(setting.if && sibling && sibling.hasAttribute("_else")){



if(sibling.hasAttribute("_if")){

Expand Down Expand Up @@ -334,15 +329,11 @@ function runRenderingSystem(els, data){

const current=getChildNodes(root)[i];


if(ifNot){


if(isFalse(source[ifNot]) && !target.isSameNode(current)){



if(isANode(current)){
if(isANode(current) || root.textContent.trim().length!==0){

insertBefore(root, target);

Expand Down Expand Up @@ -381,7 +372,9 @@ function runRenderingSystem(els, data){

if(target.parentNode==root){

root.replaceChild(ELSE,target);

root.removeChild(target);
insertBefore(root, ELSE);


}
Expand All @@ -391,16 +384,11 @@ function runRenderingSystem(els, data){


}else{


if(current){


// If true.

const el=current;


if(el.isSameNode(target)){

if(current && current.isSameNode(target)){

if(ELSE && ELSE.parentNode!=null){

Expand All @@ -416,7 +404,8 @@ function runRenderingSystem(els, data){



root.replaceChild(target,ELSE)
root.removeChild(ELSE);
insertBefore(root, target);



Expand All @@ -428,16 +417,6 @@ function runRenderingSystem(els, data){
}

}


else{

insertBefore(root, target)

}


}



Expand Down
79 changes: 31 additions & 48 deletions inter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

(function(){

/**
* Interjs
* Version - 2.0.6
* Version - 2.0.7
* MIT LICENSED BY - Denis Power
* Repo - https://github.com/interjs/inter
* 2021-2022
Expand Down Expand Up @@ -1203,10 +1202,16 @@ function getChildNodes(root){

const nodes=new Array();

root.childNodes.forEach((node)=>{
root.childNodes.forEach((node, index)=>{

if(node.nodeType==1 || node.nodeType==3 && !node.textContent.trim().length==0){

if(node.index==void 0){

node.index=index;

}

nodes.push(node);

}
Expand Down Expand Up @@ -1247,8 +1252,7 @@ function getChildNodes(root){

const{
in:IN,
data,

data
}=obj;

if(!(typeof IN==="string")){
Expand Down Expand Up @@ -1309,8 +1313,9 @@ function getChildNodes(root){
function parseAttrs(container){

let index=-1;
const children=container.childNodes;

for(const child of container.children){
for(const child of children){

index++;

Expand All @@ -1324,12 +1329,12 @@ function getChildNodes(root){
}

child.index=index;


if(child.nodeType==3)continue;

const sibling=child.nextElementSibling,
previous=child.previousElementSibling;


if(child.children.length>0){

parseAttrs(child)
Expand Down Expand Up @@ -1386,7 +1391,7 @@ function getChildNodes(root){
ParserWarning(`
The parser found an element with an "_else" attribute,
but there is not an element by attribute "_if" before it.
but there is not an element with attribute "_if" before it.
`)

Expand Down Expand Up @@ -1473,7 +1478,7 @@ function getChildNodes(root){
}
}

parseAttrs(theContainer)
parseAttrs(theContainer)

const reactor=runRenderingSystem(els, data);

Expand Down Expand Up @@ -1506,17 +1511,14 @@ function runRenderingSystem(els, data){
root
}=el;

const current=getChildNodes(root)[i];

const current=getChildNodes(root)[i];

if(ifNot){


if(isFalse(source[ifNot]) && !target.isSameNode(current)){



if(isANode(current)){
if(isANode(current) || root.textContent.trim().length!==0){

insertBefore(root, target);

Expand Down Expand Up @@ -1556,31 +1558,24 @@ function runRenderingSystem(els, data){

}else if(ELSE){

if(current && current.isSameNode(ELSE)){

}else{

if(target.parentNode==root){

root.replaceChild(ELSE,target);

}
if(target.parentNode==root){

}
root.removeChild(target);
insertBefore(root, ELSE);


}


}



}else{


if(current){

const el=current;


if(el.isSameNode(target)){
if(current && current.isSameNode(target)){

if(ELSE && ELSE.parentNode!=null){

Expand All @@ -1592,30 +1587,18 @@ function runRenderingSystem(els, data){
}
else if(ELSE && ELSE.parentNode!=null){



root.replaceChild(target,ELSE)


root.removeChild(ELSE);
insertBefore(root, target);

}

else{

insertBefore(root, target);
insertBefore(root, target);


}

}


else{

insertBefore(root, target)

}


}

Expand Down Expand Up @@ -1643,7 +1626,6 @@ function insertBefore(root, target){
for(const child of children){

if(child.index>target.index){


root.insertBefore(target, child);

Expand All @@ -1657,6 +1639,7 @@ function insertBefore(root, target){

} else{


root.appendChild(target);

}
Expand Down Expand Up @@ -4876,7 +4859,7 @@ Object.freeze(Backend.prototype);
window.template=template;
window.Backend=Backend;

console.log("The global version 2.0.6 of Inter was successfully loaded.")
console.log("The global version 2.0.7 of Inter was successfully loaded.")

})();

5 changes: 2 additions & 3 deletions inter.min.js

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inter",
"version": "2.0.6",
"version": "2.0.7",
"description": "The javascript framework to build highly interactive front-end web applications.",
"author": "Denis Power",
"license": "MIT",
Expand All @@ -10,8 +10,5 @@
"devDependencies":{
"node":">=14.18.0"

},
"dependencies":{
"UglifyJS":">=3.3.9"
}
}

0 comments on commit e0839d1

Please sign in to comment.