Skip to content

Commit

Permalink
Update to v2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisPower1 committed Feb 18, 2023
1 parent 2ea2a75 commit 146f3e0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 843 deletions.
44 changes: 36 additions & 8 deletions inter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Interjs
* Version - 2.1.3
* Version - 2.1.4
* MIT LICENSED BY - Denis Power
* Repo - https://github.com/interjs/inter
* 2021-2023
* 2021 - 2023
* GENERATED BY INTER GLOBAL BUILDER
*
*/
Expand Down Expand Up @@ -51,6 +51,26 @@
one or more of those options as plain Javascript object.`);
}

function runIllegalAttrsPropWarning(prop) {
const styleProp = `You should not use the style attribute(in attrs object) to create styles for the element,
use the "styles" object instead, like:
{
tag: "p", text: "Some text", styles: { color: "green" }
}
`;

const event = `You shoud not use "${prop}" as an attribute name, it seems to be a dom event,
use it as property of the "events" object, like:
{
tag: "button", text: "Click me", events: { ${prop}: () => { //Some code here } }
}
`;

consW(prop.startsWith("on") ? event : styleProp);
}

function runCanNotDefineReactivePropWarning() {
consW(`Inter failed to define reactivity
in a plain Javascript object, because it is not configurable.`);
Expand Down Expand Up @@ -1645,8 +1665,14 @@
Object.entries(attrs).forEach((attr) => {
// eslint-disable-next-line prefer-const
let [name, value] = attr;
let hasWarning = false;
const specialAttrs = new Set(["value", "currentTime", "checked"]);

if ((name.startsWith("on") && validDomEvent(name)) || name == "style") {
runIllegalAttrsPropWarning(name);
hasWarning = true;
}

const setAttr = (attrValue) => {
if (isDefined(attrValue) && !isFalse(attrValue)) {
if (!specialAttrs.has(name)) container.setAttribute(name, attrValue);
Expand All @@ -1655,12 +1681,14 @@
container.template.attrs[name] = attrValue;
};

if (isCallable(value)) {
value = value();
if (!hasWarning) {
if (isCallable(value)) {
value = value();

setAttr(value);
} else {
setAttr(value);
setAttr(value);
} else {
setAttr(value);
}
}
});
}
Expand Down Expand Up @@ -3288,5 +3316,5 @@
window.template = template;
window.toAttrs = toAttrs;
window.Backend = Backend;
console.log("The global version 2.1.3 of Inter was loaded successfully.");
console.log("The global version 2.1.4 of Inter was loaded successfully.");
})();
4 changes: 2 additions & 2 deletions inter.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 146f3e0

Please sign in to comment.