Skip to content

Commit 799caaa

Browse files
authored
Merge pull request #17 from DenisPower1/Edit
Update inter.js
2 parents 7e01713 + 311f10c commit 799caaa

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

inter.js

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Inter.
3-
* Version: 1.1.2
3+
* Version: 1.1.3
44
* 2021 - by Denis Power.
55
* https://github.com/DenisPower1/inter
66
* A Javascript framework to build interactive frontend applications.
@@ -81,6 +81,7 @@ function Warning(err){
8181
}
8282

8383
function getId(id){
84+
if(document instanceof Document){
8485
const theId=document.getElementById(id);
8586
if(theId== void 0){
8687
SyntaxErr(`
@@ -91,6 +92,9 @@ if(theId== void 0){
9192

9293
return theId;
9394
}
95+
}else{
96+
return void 0;
97+
}
9498
}
9599

96100
function consoleWarnig(msm){
@@ -103,16 +107,28 @@ function consoleWarnig(msm){
103107
}
104108

105109
function TEXT(node){
110+
if(document instanceof Document){
106111
return document.createTextNode(node);
112+
}else{
113+
return void 0;
114+
}
107115
}
108116
function hasAttr(el, attr){
117+
if(el!=void 0){
109118
if(isElement(el)){
110119
return el.hasAttribute(attr);
111120
}
121+
}else{
122+
return false;
123+
}
112124
}
113125

114126
function CreatEL(EL){
127+
if(document instanceof Document){
115128
return document.createElement(EL)
129+
}else{
130+
return void 0;
131+
}
116132
};
117133

118134
function setAttr(el,attr, value){
@@ -435,6 +451,7 @@ return first>second ? first : second;
435451
}
436452
function noTextTag(first,second){
437453

454+
//These are just the tags that must not be rerendered.
438455
const noTextTag={
439456
video:!0,
440457
audio:!0,
@@ -616,6 +633,7 @@ const parser={
616633
}
617634

618635

636+
619637
/**
620638
* Changing the onload method, for inputHandler be more performant.
621639
*
@@ -769,13 +787,13 @@ var validate=new Proxy(validator,{
769787
const INTER=new HTML();
770788
const Inter=new Proxy(INTER,{
771789
set(...values){
772-
SyntaxErr(`You can not set any propriety in object Inter,
790+
SyntaxErr(`You can not set any property in Inter object,
773791
this is a fatal action.
774792
`);
775793
return false;
776794
},
777795
deleteProperty(...values){
778-
SyntaxErr(`Fatal error: do not try to delete any propriety of Inter object`);
796+
SyntaxErr(`Fatal error: do not try to delete any property of Inter object`);
779797
return false;
780798
},
781799
getPrototypeOf(Target){
@@ -835,7 +853,7 @@ The argument in data.query() must be an object.
835853
}
836854
let filtered=IN.filter(item=>{
837855
if(!hasOwn.call(item,query)){
838-
console.log(`There was not found a property called ${query} in target object.`)
856+
console.log(`It's was not found a property called "${query}" in target object, in data.query()`)
839857
}
840858
const keyword=item[query];
841859
let lower=lowerCase.call(keyword);
@@ -1010,7 +1028,7 @@ function isaNodeElement(supposedElement){
10101028

10111029
/**
10121030
*There is already a function that do a work similiar to this, called
1013-
*isElement(), but that function does not work as espected in Inter.renderIf() checking,
1031+
*isElement(), but that function does not work as expected in Inter.renderIf() checking,
10141032
* that's why I'm doing
10151033
* a strong checking with this one.
10161034
*/
@@ -1152,8 +1170,7 @@ definePro(Inter, "renderIf",(obj)=>{
11521170

11531171

11541172
else{
1155-
SyntaxErr(`The last rendered children in element by id ${IN} is at index ${allundeepChildren} and
1156-
to render a children at index ${pos}.
1173+
SyntaxErr(`Invalid index, it's impossible to render the element at index "${pos}"!
11571174
`)
11581175

11591176
}
@@ -1207,7 +1224,7 @@ class SIMULATE{
12071224
* semulate.typing({
12081225
* in:"container",
12091226
* setting:[{
1210-
* text:"Hey, i'm Denis the creator of Inter.",
1227+
* text:"Hey, I'm Denis the creator of Inter.",
12111228
* speed:100
12121229
* }]
12131230
* })
@@ -1336,7 +1353,8 @@ const{
13361353
elements,
13371354
}=obj;
13381355

1339-
//Note: render is just usual for reative template.
1356+
//Note: render is just usual for reactive template.
1357+
13401358
/**
13411359
* templates({
13421360
* elements:[{
@@ -1454,15 +1472,15 @@ let tags=array.create(null);
14541472
const[evName,evValue]=ev;
14551473

14561474
childElement[evName]=evValue;
1457-
childElement[`_${evName}`]=evValue; //Reative template
1458-
childElement.rerender=true; // Reative listining.
1475+
childElement[`_${evName}`]=evValue; //Reactive template
1476+
childElement.rerender=true; // Reactive listing.
14591477
})
14601478

14611479
Object.values(_handlers).forEach(handler=>{
14621480

14631481
if(isCallable(handler)){
14641482
childElement.rerender=true;
1465-
return _handlers[handler].call(childElement);
1483+
handler.call(childElement);
14661484
}
14671485
})
14681486
Object.entries(_styles).forEach(sty=>{
@@ -1518,7 +1536,7 @@ let tags=array.create(null);
15181536

15191537
if(isCallable(value)){
15201538
grand_son.rerender=true;
1521-
value()
1539+
value.call(grand_son)
15221540
}
15231541

15241542
})
@@ -2014,7 +2032,7 @@ BACKEND.prototype.request=function(obj){
20142032

20152033
}
20162034
}
2017-
const backend=new BACKEND();
2035+
const backend=Object.freeze(new BACKEND());
20182036

20192037
const globalNativeEventListener={
20202038

0 commit comments

Comments
 (0)