Skip to content

Commit 146f3e0

Browse files
committed
Update to v2.1.4
1 parent 2ea2a75 commit 146f3e0

4 files changed

Lines changed: 40 additions & 843 deletions

File tree

inter.js

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* Interjs
3-
* Version - 2.1.3
3+
* Version - 2.1.4
44
* MIT LICENSED BY - Denis Power
55
* Repo - https://github.com/interjs/inter
6-
* 2021-2023
6+
* 2021 - 2023
77
* GENERATED BY INTER GLOBAL BUILDER
88
*
99
*/
@@ -51,6 +51,26 @@
5151
one or more of those options as plain Javascript object.`);
5252
}
5353

54+
function runIllegalAttrsPropWarning(prop) {
55+
const styleProp = `You should not use the style attribute(in attrs object) to create styles for the element,
56+
use the "styles" object instead, like:
57+
58+
{
59+
tag: "p", text: "Some text", styles: { color: "green" }
60+
}
61+
`;
62+
63+
const event = `You shoud not use "${prop}" as an attribute name, it seems to be a dom event,
64+
use it as property of the "events" object, like:
65+
66+
{
67+
tag: "button", text: "Click me", events: { ${prop}: () => { //Some code here } }
68+
}
69+
`;
70+
71+
consW(prop.startsWith("on") ? event : styleProp);
72+
}
73+
5474
function runCanNotDefineReactivePropWarning() {
5575
consW(`Inter failed to define reactivity
5676
in a plain Javascript object, because it is not configurable.`);
@@ -1645,8 +1665,14 @@
16451665
Object.entries(attrs).forEach((attr) => {
16461666
// eslint-disable-next-line prefer-const
16471667
let [name, value] = attr;
1668+
let hasWarning = false;
16481669
const specialAttrs = new Set(["value", "currentTime", "checked"]);
16491670

1671+
if ((name.startsWith("on") && validDomEvent(name)) || name == "style") {
1672+
runIllegalAttrsPropWarning(name);
1673+
hasWarning = true;
1674+
}
1675+
16501676
const setAttr = (attrValue) => {
16511677
if (isDefined(attrValue) && !isFalse(attrValue)) {
16521678
if (!specialAttrs.has(name)) container.setAttribute(name, attrValue);
@@ -1655,12 +1681,14 @@
16551681
container.template.attrs[name] = attrValue;
16561682
};
16571683

1658-
if (isCallable(value)) {
1659-
value = value();
1684+
if (!hasWarning) {
1685+
if (isCallable(value)) {
1686+
value = value();
16601687

1661-
setAttr(value);
1662-
} else {
1663-
setAttr(value);
1688+
setAttr(value);
1689+
} else {
1690+
setAttr(value);
1691+
}
16641692
}
16651693
});
16661694
}
@@ -3288,5 +3316,5 @@
32883316
window.template = template;
32893317
window.toAttrs = toAttrs;
32903318
window.Backend = Backend;
3291-
console.log("The global version 2.1.3 of Inter was loaded successfully.");
3319+
console.log("The global version 2.1.4 of Inter was loaded successfully.");
32923320
})();

inter.min.js

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

0 commit comments

Comments
 (0)