@duckafire/html.js 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -9
- package/html.js +12 -7
- package/html.min.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,7 +17,8 @@ This is a web component library, thought to be:
|
|
|
17
17
|
Just copy and paste this code chunk in your HTML file:
|
|
18
18
|
|
|
19
19
|
``` html
|
|
20
|
-
<script src="https://cdn.jsdelivr.net/
|
|
20
|
+
<script src="https://cdn.jsdelivr.net/npm/@duckafire/html.js@0.0.2-3/html.min.js"></script>
|
|
21
|
+
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
> [!TIP]
|
|
@@ -27,12 +28,12 @@ After this, run the JavaScript code below:
|
|
|
27
28
|
|
|
28
29
|
``` html
|
|
29
30
|
<script>
|
|
30
|
-
|
|
31
|
+
declare_htmljs();
|
|
31
32
|
</script>
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
> [!NOTE]
|
|
35
|
-
> See more about `
|
|
36
|
+
> See more about `declare_htmljs` [here](#start-library).
|
|
36
37
|
|
|
37
38
|
## How to use
|
|
38
39
|
|
|
@@ -41,12 +42,14 @@ After this, run the JavaScript code below:
|
|
|
41
42
|
As mentioned earlier on, it is necessary call the functions bellow to
|
|
42
43
|
start the library:
|
|
43
44
|
|
|
44
|
-
* `{}
|
|
45
|
+
* `{} declare_htmljs( [prefix: string = ""], [createObject: boolean = false], [useUpperCase: boolean = false] )`
|
|
45
46
|
* `prefix`: prefixs the name of the functions/methods that are
|
|
46
47
|
used to create the elements.
|
|
47
48
|
* `createObject`: specifics that the methods have to be declared
|
|
48
49
|
in a new object, that it will be created by the
|
|
49
50
|
functions.
|
|
51
|
+
* `useUpperCase`: specifics that the methods names have to be formated by
|
|
52
|
+
upper case characters, instead lower case characteres.
|
|
50
53
|
|
|
51
54
|
> [!NOTE]
|
|
52
55
|
> If `createObject != true`, the methods will be declared in `window`, that
|
|
@@ -68,9 +71,8 @@ below:
|
|
|
68
71
|
|
|
69
72
|
``` js
|
|
70
73
|
// create a <div> that it contains two
|
|
71
|
-
// text nodes and a
|
|
72
|
-
div(
|
|
73
|
-
null,
|
|
74
|
+
// "text nodes" and a <br> element
|
|
75
|
+
div( null,
|
|
74
76
|
"foo foo"
|
|
75
77
|
br();
|
|
76
78
|
"bar bar"
|
|
@@ -88,8 +90,8 @@ will explain their structure.
|
|
|
88
90
|
string, a *text node* will added to the element.
|
|
89
91
|
* `closeTag`: an optional thing, to explicit the end of the element creation. I
|
|
90
92
|
recommend that it to be equal the itself function (like the previous
|
|
91
|
-
example). See [this](#closing-the-element-creation) to learn how to
|
|
92
|
-
this optional parameter.
|
|
93
|
+
example). See [this](#closing-the-element-creation) to learn how to
|
|
94
|
+
disable this optional parameter.
|
|
93
95
|
|
|
94
96
|
> [!IMPORTANT]
|
|
95
97
|
> Deprecated tags are not available.
|
package/html.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
// Zlib License
|
|
2
4
|
//
|
|
3
5
|
// Copyright (C) 2025 DuckAfire <duckafire.github.io/nest>
|
|
@@ -18,9 +20,7 @@
|
|
|
18
20
|
// misrepresented as being the original software.
|
|
19
21
|
// 3. This notice may not be removed or altered from any source distribution.
|
|
20
22
|
|
|
21
|
-
"use strict";
|
|
22
23
|
let __htmljs_ignore_last__ = 1;
|
|
23
|
-
const __HTMLJS_FIRST_CONTAINER_TAG_ID__ = 12;
|
|
24
24
|
|
|
25
25
|
const __htmljs_is_not_object__ = (thing) =>
|
|
26
26
|
{
|
|
@@ -30,7 +30,8 @@ const __htmljs_is_not_object__ = (thing) =>
|
|
|
30
30
|
const __htmljs_element_tags__ = [
|
|
31
31
|
// NO-containers
|
|
32
32
|
"area", "base", "br", "col", "hr", "img", "input", "link",
|
|
33
|
-
"meta", "source", "track", "wbr",
|
|
33
|
+
"meta", "source", "track", "wbr",
|
|
34
|
+
// wbr id == 11, so the first "container" is #12
|
|
34
35
|
|
|
35
36
|
// containers
|
|
36
37
|
"a", "abbr", "address", "article", "audio", "b", "bdi", "bdo",
|
|
@@ -105,16 +106,20 @@ const htmljs_set_ignore_last = (ignore) =>
|
|
|
105
106
|
__htmljs_ignore_last__ = ignore ? 1 : 0;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
const declare_htmljs = (prefix, createObject) =>
|
|
109
|
+
const declare_htmljs = (prefix, createObject, useUpperCase) =>
|
|
109
110
|
{
|
|
110
111
|
const DEST = createObject ? {} : window;
|
|
111
112
|
const PREF = prefix || "";
|
|
113
|
+
let tag;
|
|
112
114
|
|
|
113
115
|
__htmljs_element_tags__.forEach((elementTag, id) =>
|
|
114
116
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
tag = PREF + elementTag;
|
|
118
|
+
|
|
119
|
+
DEST[ (useUpperCase ? tag.toUpperCase() : tag) ] =
|
|
120
|
+
(id < 12) // 12 == first "container"
|
|
121
|
+
? (properties) => __htmljs_core__(elementTag, properties)
|
|
122
|
+
: (properties, ...children) => __htmljs_core__(elementTag, properties, ...children);
|
|
118
123
|
});
|
|
119
124
|
|
|
120
125
|
return DEST;
|
package/html.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __htmljs_ignore_last__=1;const
|
|
1
|
+
"use strict";let __htmljs_ignore_last__=1;const __htmljs_is_not_object__=t=>"object"!=typeof t||Array.isArray(t),__htmljs_element_tags__=["area","base","br","col","hr","img","input","link","meta","source","track","wbr","a","abbr","address","article","audio","b","bdi","bdo","blockquote","body","button","canvas","caption","cite","code","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","html","i","iframe","ins","kbd","label","legend","li","main","map","mark","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","samp","script","section","select","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","ul","var","video"],__htmljs_core__=(t,e,...o)=>{const r=document.createElement(t);if(void 0!==e){let t="";const _=o.length-__htmljs_ignore_last__;if(null!==e){if(__htmljs_is_not_object__(e))throw new TypeError(`Excepting Object to \`htmlProperties\`, instead "${typeof e}".`);for(const t in e)r[t]=e[t]}for(let e=0;e<_;e++)if("string"!=typeof o[e]){if(__htmljs_is_not_object__(o[e]))throw new TypeError(`Excepting Object or String to \`children[${e}]\`, instead "${typeof o[e]}".`);""!=t&&(r.appendChild(document.createTextNode(t)),t="");try{r.appendChild(o[e])}catch(t){console.error(t);break}}else t+=(""==t?"":" ")+o[e];null!==t&&r.appendChild(document.createTextNode(t))}return r},htmljs_set_ignore_last=t=>{__htmljs_ignore_last__=t?1:0},declare_htmljs=(t,e,o)=>{const r=e?{}:window,_=t||"";let l;return __htmljs_element_tags__.forEach((t,e)=>{l=_+t,r[o?l.toUpperCase():l]=e<12?e=>__htmljs_core__(t,e):(e,...o)=>__htmljs_core__(t,e,...o)}),r};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckafire/html.js",
|
|
3
3
|
"author": "duckafire",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"license": "
|
|
4
|
+
"version": "0.0.3",
|
|
5
|
+
"license": "Zlib",
|
|
6
6
|
"description": "Just a very simple components library.",
|
|
7
7
|
"keywords": ["front-end", "client", "html", "dom", "light", "components", "web", "simple", "minimalist", "easy"],
|
|
8
8
|
"devDependencies": {
|