@duckafire/html.js 0.0.2-3 → 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 CHANGED
@@ -42,12 +42,14 @@ After this, run the JavaScript code below:
42
42
  As mentioned earlier on, it is necessary call the functions bellow to
43
43
  start the library:
44
44
 
45
- * `{} declare_htmljs( [prefix: string = ""], [createObject: boolean = false] )`
45
+ * `{} declare_htmljs( [prefix: string = ""], [createObject: boolean = false], [useUpperCase: boolean = false] )`
46
46
  * `prefix`: prefixs the name of the functions/methods that are
47
47
  used to create the elements.
48
48
  * `createObject`: specifics that the methods have to be declared
49
49
  in a new object, that it will be created by the
50
50
  functions.
51
+ * `useUpperCase`: specifics that the methods names have to be formated by
52
+ upper case characters, instead lower case characteres.
51
53
 
52
54
  > [!NOTE]
53
55
  > If `createObject != true`, the methods will be declared in `window`, that
@@ -69,9 +71,8 @@ below:
69
71
 
70
72
  ``` js
71
73
  // create a <div> that it contains two
72
- // text nodes and a `<br>` element
73
- div(
74
- null,
74
+ // "text nodes" and a <br> element
75
+ div( null,
75
76
  "foo foo"
76
77
  br();
77
78
  "bar bar"
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", // wbr id == 11
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
- DEST[ PREF + elementTag ] = (id < __HTMLJS_FIRST_CONTAINER_TAG_ID__)
116
- ? (properties) => __htmljs_core__(elementTag, properties)
117
- : (properties, ...children) => __htmljs_core__(elementTag, properties, ...children);
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 __HTMLJS_FIRST_CONTAINER_TAG_ID__=12,__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,..._)=>{const o=document.createElement(t);if(void 0!==e){let t="";const r=_.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)o[t]=e[t]}for(let e=0;e<r;e++)if("string"!=typeof _[e]){if(__htmljs_is_not_object__(_[e]))throw new TypeError(`Excepting Object or String to \`children[${e}]\`, instead "${typeof _[e]}".`);""!=t&&(o.appendChild(document.createTextNode(t)),t="");try{o.appendChild(_[e])}catch(t){console.error(t);break}}else t+=(""==t?"":" ")+_[e];null!==t&&o.appendChild(document.createTextNode(t))}return o},htmljs_set_ignore_last=t=>{__htmljs_ignore_last__=t?1:0},declare_htmljs=(t,e)=>{const _=e?{}:window,o=t||"";return __htmljs_element_tags__.forEach((t,e)=>{_[o+t]=e<12?e=>__htmljs_core__(t,e):(e,..._)=>__htmljs_core__(t,e,..._)}),_};
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@duckafire/html.js",
3
3
  "author": "duckafire",
4
- "version": "0.0.2-3",
4
+ "version": "0.0.3",
5
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"],