@duckafire/html.js 0.2.1 → 0.2.2

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
@@ -91,10 +91,12 @@ below:
91
91
  ``` js
92
92
  // create a <div> that it contains two
93
93
  // "text nodes" and a <br> element
94
- div( null,
95
- "foo foo"
96
- br();
97
- "bar bar"
94
+ div( {className: "foo"},
95
+ "Lorem ipsum",
96
+ br(),
97
+ span( null,
98
+ "Lorem ipsum",
99
+ span),
98
100
  input( {type: "text", value: "foobar", readOnly: "~"}),
99
101
  div);
100
102
  ```
package/html.js CHANGED
@@ -132,7 +132,7 @@ const __htmljs_core__ = (elementTag, htmlProperties, ...children) =>
132
132
 
133
133
  const VALUE = (htmlProperties[PROPERTY] == "~" ? PROPERTY.toLowerCase() : htmlProperties[PROPERTY]);
134
134
 
135
- if(ELEM[PROPERTY])
135
+ if(ELEM[PROPERTY] !== undefined || PROPERTY == "className")
136
136
  ELEM[PROPERTY] = VALUE;
137
137
  else
138
138
  ELEM.setAttribute(PROPERTY, VALUE);
package/html.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";let __htmljs_ignore_last__=1,__htmljs_debug_func__=console.warn;const __htmljs_is_not_object__=e=>"object"!=typeof e||Array.isArray(e),__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_set_prefixed_property__=(e,t,_,r)=>{t.setAttribute(e+"-"+_,r)},__htmljs_data_sets__=(e,t,_)=>{__htmljs_set_prefixed_property__("data",e,t,_)},__htmljs_aria_attributes__=(e,t,_)=>{__htmljs_set_prefixed_property__("aria",e,t,_)},__htmljs_event_listeners__=(e,t,_)=>{if(Array.isArray(_))for(const r of _)e.addEventListener(t,r);else e.addEventListener(t,_)},__htmljs_css_rules__=(e,t,_)=>{"-"==t.charAt(0)?e.style.setProperty(t,_):e.style[t]=_},__htmljs_treat_special_properties__=(e,t,_)=>{let r;switch(t){case"dataSets":r=__htmljs_data_sets__;break;case"ariaAttributes":r=__htmljs_aria_attributes__;break;case"eventListeners":r=__htmljs_event_listeners__;break;case"cssRules":r=__htmljs_css_rules__;break;default:return!1}if(__htmljs_is_not_object__(_[t]))return __htmljs_debug_func__(new TypeError(`Invalid value attributed to \`${t}\`, expecting an object.`)),!1;for(const s in _[t])r(e,s,_[t][s]);return!0},__htmljs_core__=(e,t,..._)=>{const r=document.createElement(e);if(void 0!==t){let e="";const s=_.length-__htmljs_ignore_last__;if(null!==t){__htmljs_is_not_object__(t)&&(__htmljs_debug_func__(new TypeError(`Excepting Object to \`htmlProperties\`, instead "${typeof t}".`)),t={});for(const e in t){if(__htmljs_treat_special_properties__(r,e,t))continue;const _="~"==t[e]?e.toLowerCase():t[e];r[e]?r[e]=_:r.setAttribute(e,_)}}for(let t=0;t<s;t++)if("string"!=typeof _[t])if(_[t]instanceof HTMLElement){""!=e&&(r.appendChild(document.createTextNode(e)),e="");try{r.appendChild(_[t])}catch(e){__htmljs_debug_func__(e);break}}else __htmljs_debug_func__(new TypeError(`Excepting Object or String to \`children[${t}]\`, instead "${typeof _[t]}".`));else e+=(""==e?"":" ")+_[t];""!=e&&r.appendChild(document.createTextNode(e))}return r},htmljs_set_ignore_last=e=>{__htmljs_ignore_last__=e?1:0},htmljs_set_debug_mode=e=>{const t=typeof e;if("number"!=t)throw new TypeError(`Invalid mode type: "${t}". Use only integer numbers.`);if(e>2)throw new RangeError(`Invalid mode value: "${e}". Use only 0, 1, or 2.`);__htmljs_debug_func__=[()=>{},console.warn,e=>{throw e}][Math.floor(e)]},declare_htmljs=(...e)=>{let t,_,r;null!==e[0]&&"object"==typeof e[0]?({prefix:t,createObject:_,useUpperCase:r}=e[0]):[t,_,r]=e;const s=_?{}:window,o=t||"";let a;return __htmljs_element_tags__.forEach((e,t)=>{a=o+e,s[r?a.toUpperCase():a]=t<12?t=>__htmljs_core__(e,t):(t,..._)=>__htmljs_core__(e,t,..._)}),s};
1
+ "use strict";let __htmljs_ignore_last__=1,__htmljs_debug_func__=console.warn;const __htmljs_is_not_object__=e=>"object"!=typeof e||Array.isArray(e),__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_set_prefixed_property__=(e,t,_,r)=>{t.setAttribute(e+"-"+_,r)},__htmljs_data_sets__=(e,t,_)=>{__htmljs_set_prefixed_property__("data",e,t,_)},__htmljs_aria_attributes__=(e,t,_)=>{__htmljs_set_prefixed_property__("aria",e,t,_)},__htmljs_event_listeners__=(e,t,_)=>{if(Array.isArray(_))for(const r of _)e.addEventListener(t,r);else e.addEventListener(t,_)},__htmljs_css_rules__=(e,t,_)=>{"-"==t.charAt(0)?e.style.setProperty(t,_):e.style[t]=_},__htmljs_treat_special_properties__=(e,t,_)=>{let r;switch(t){case"dataSets":r=__htmljs_data_sets__;break;case"ariaAttributes":r=__htmljs_aria_attributes__;break;case"eventListeners":r=__htmljs_event_listeners__;break;case"cssRules":r=__htmljs_css_rules__;break;default:return!1}if(__htmljs_is_not_object__(_[t]))return __htmljs_debug_func__(new TypeError(`Invalid value attributed to \`${t}\`, expecting an object.`)),!1;for(const s in _[t])r(e,s,_[t][s]);return!0},__htmljs_core__=(e,t,..._)=>{const r=document.createElement(e);if(void 0!==t){let e="";const s=_.length-__htmljs_ignore_last__;if(null!==t){__htmljs_is_not_object__(t)&&(__htmljs_debug_func__(new TypeError(`Excepting Object to \`htmlProperties\`, instead "${typeof t}".`)),t={});for(const e in t){if(__htmljs_treat_special_properties__(r,e,t))continue;const _="~"==t[e]?e.toLowerCase():t[e];void 0!==r[e]||"className"==e?r[e]=_:r.setAttribute(e,_)}}for(let t=0;t<s;t++)if("string"!=typeof _[t])if(_[t]instanceof HTMLElement){""!=e&&(r.appendChild(document.createTextNode(e)),e="");try{r.appendChild(_[t])}catch(e){__htmljs_debug_func__(e);break}}else __htmljs_debug_func__(new TypeError(`Excepting Object or String to \`children[${t}]\`, instead "${typeof _[t]}".`));else e+=(""==e?"":" ")+_[t];""!=e&&r.appendChild(document.createTextNode(e))}return r},htmljs_set_ignore_last=e=>{__htmljs_ignore_last__=e?1:0},htmljs_set_debug_mode=e=>{const t=typeof e;if("number"!=t)throw new TypeError(`Invalid mode type: "${t}". Use only integer numbers.`);if(e>2)throw new RangeError(`Invalid mode value: "${e}". Use only 0, 1, or 2.`);__htmljs_debug_func__=[()=>{},console.warn,e=>{throw e}][Math.floor(e)]},declare_htmljs=(...e)=>{let t,_,r;null!==e[0]&&"object"==typeof e[0]?({prefix:t,createObject:_,useUpperCase:r}=e[0]):[t,_,r]=e;const s=_?{}:window,o=t||"";let a;return __htmljs_element_tags__.forEach((e,t)=>{a=o+e,s[r?a.toUpperCase():a]=t<12?t=>__htmljs_core__(e,t):(t,..._)=>__htmljs_core__(e,t,..._)}),s};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duckafire/html.js",
3
3
  "author": "duckafire",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
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"],