typed-dom
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.17 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
/*! typed-dom v0.0.18 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
require = function e(t, n, r) { | ||
@@ -266,13 +266,9 @@ function s(o, u) { | ||
].reduce(function (obj, tag) { | ||
obj[tag] = function (attrs, children, factory) { | ||
if (!children || typeof children === 'function') { | ||
factory = children; | ||
children = attrs; | ||
attrs = {}; | ||
} | ||
return builder_1.build(factory || function () { | ||
return obj[tag] = function (attrs, children, factory) { | ||
return !attrs || !children || typeof children === 'function' ? builder_1.build(children || function () { | ||
return document.createElement(tag); | ||
}, {}, attrs) : builder_1.build(factory || function () { | ||
return document.createElement(tag); | ||
}, attrs, children); | ||
}; | ||
return obj; | ||
}, obj; | ||
}, {}); | ||
@@ -279,0 +275,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.17 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
require=function e(t,r,n){function o(c,a){if(!r[c]){if(!t[c]){var u="function"==typeof require&&require;if(!a&&u)return u(c,!0);if(i)return i(c,!0);var d=new Error("Cannot find module '"+c+"'");throw d.code="MODULE_NOT_FOUND",d}var f=r[c]={exports:{}};t[c][0].call(f.exports,function(e){var r=t[c][1][e];return o(r?r:e)},f,f.exports,e,t,r,n)}return r[c].exports}for(var i="function"==typeof require&&require,c=0;c<n.length;c++)o(n[c]);return o}({1:[function(e,t,r){},{}],2:[function(e,t,r){arguments[4][1][0].apply(r,arguments)},{dup:1}],3:[function(e,t,r){"use strict";function n(e,t,r){function n(e){var t={};return Object.keys(e).reduce(function(e,r){return t[r]=e[r],Object.defineProperty(e,r,{get:function(){return t[r]},set:function(e){var n=t[r];t[r]=e,o.replaceChild(e.element,n.element)}}),e},e)}var o=e();if(void 0===r)return Object.freeze({element:o,children:r});var i="string"==typeof r?"text":Array.isArray(r)?"array":"object";switch(i){case"text":r=document.createTextNode(r),void o.appendChild(r);break;default:switch(void Object.keys(t).forEach(function(e){return o.setAttribute(e,t[e]||"")}),void Object.keys(r).forEach(function(e){return void o.appendChild(r[e].element)}),i){case"array":void Object.freeze(r);break;case"object":void n(r)}}return Object.freeze({element:o,get children(){switch(i){case"text":return r.data;default:return r}},set children(e){switch(i){case"text":r.data=e,e=r;break;case"array":e=Object.freeze(e),void e.reduce(function(e,t){var r=e.indexOf(t);return r===-1?e:(void e.splice(r,1),e)},r.slice()).map(function(e){return e.element}).forEach(function(e){return void e.remove()}),void e.map(function(e){return e.element}).forEach(function(e){return void o.appendChild(e)});break;case"object":void Object.keys(e).forEach(function(t){return void o.replaceChild(e[t].element,r[t].element)}),e=n(e)}r=e}})}r.build=n},{}],4:[function(e,t,r){"use strict";var n=e("./builder");r.TypedHTML=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","datalist","dd","del","dfn","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","map","mark","marquee","menu","meta","meter","nav","nextid","nobr","noframes","noscript","object","ol","optgroup","option","p","param","picture","plaintext","pre","progress","q","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","sup","table","tbody","td","template","textarea","tfoot","th","thead","title","tr","track","tt","u","ul","var","video","wbr","xmp","custom"].reduce(function(e,t){return e[t]=function(e,r,o){return r&&"function"!=typeof r||(o=r,r=e,e={}),n.build(o||function(){return document.createElement(t)},e,r)},e},{})},{"./builder":3}],5:[function(e,t,r){"use strict";var n=e("./dom/html");r.default=n.TypedHTML},{"./dom/html":4}],6:[function(e,t,r){arguments[4][1][0].apply(r,arguments)},{dup:1}],"typed-dom":[function(e,t,r){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}n(e("./src/export"));var o=e("./src/export");r.default=o.default,r.__esModule=!0},{"./src/export":5}]},{},[1,2,6,"typed-dom"]); | ||
/*! typed-dom v0.0.18 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
require=function e(t,r,n){function o(c,a){if(!r[c]){if(!t[c]){var u="function"==typeof require&&require;if(!a&&u)return u(c,!0);if(i)return i(c,!0);var d=new Error("Cannot find module '"+c+"'");throw d.code="MODULE_NOT_FOUND",d}var f=r[c]={exports:{}};t[c][0].call(f.exports,function(e){var r=t[c][1][e];return o(r?r:e)},f,f.exports,e,t,r,n)}return r[c].exports}for(var i="function"==typeof require&&require,c=0;c<n.length;c++)o(n[c]);return o}({1:[function(e,t,r){},{}],2:[function(e,t,r){arguments[4][1][0].apply(r,arguments)},{dup:1}],3:[function(e,t,r){"use strict";function n(e,t,r){function n(e){var t={};return Object.keys(e).reduce(function(e,r){return t[r]=e[r],Object.defineProperty(e,r,{get:function(){return t[r]},set:function(e){var n=t[r];t[r]=e,o.replaceChild(e.element,n.element)}}),e},e)}var o=e();if(void 0===r)return Object.freeze({element:o,children:r});var i="string"==typeof r?"text":Array.isArray(r)?"array":"object";switch(i){case"text":r=document.createTextNode(r),void o.appendChild(r);break;default:switch(void Object.keys(t).forEach(function(e){return o.setAttribute(e,t[e]||"")}),void Object.keys(r).forEach(function(e){return void o.appendChild(r[e].element)}),i){case"array":void Object.freeze(r);break;case"object":void n(r)}}return Object.freeze({element:o,get children(){switch(i){case"text":return r.data;default:return r}},set children(e){switch(i){case"text":r.data=e,e=r;break;case"array":e=Object.freeze(e),void e.reduce(function(e,t){var r=e.indexOf(t);return r===-1?e:(void e.splice(r,1),e)},r.slice()).map(function(e){return e.element}).forEach(function(e){return void e.remove()}),void e.map(function(e){return e.element}).forEach(function(e){return void o.appendChild(e)});break;case"object":void Object.keys(e).forEach(function(t){return void o.replaceChild(e[t].element,r[t].element)}),e=n(e)}r=e}})}r.build=n},{}],4:[function(e,t,r){"use strict";var n=e("./builder");r.TypedHTML=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","datalist","dd","del","dfn","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","map","mark","marquee","menu","meta","meter","nav","nextid","nobr","noframes","noscript","object","ol","optgroup","option","p","param","picture","plaintext","pre","progress","q","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","sup","table","tbody","td","template","textarea","tfoot","th","thead","title","tr","track","tt","u","ul","var","video","wbr","xmp","custom"].reduce(function(e,t){return e[t]=function(e,r,o){return e&&r&&"function"!=typeof r?n.build(o||function(){return document.createElement(t)},e,r):n.build(r||function(){return document.createElement(t)},{},e)},e},{})},{"./builder":3}],5:[function(e,t,r){"use strict";var n=e("./dom/html");r.default=n.TypedHTML},{"./dom/html":4}],6:[function(e,t,r){arguments[4][1][0].apply(r,arguments)},{dup:1}],"typed-dom":[function(e,t,r){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}n(e("./src/export"));var o=e("./src/export");r.default=o.default,r.__esModule=!0},{"./src/export":5}]},{},[1,2,6,"typed-dom"]); |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.17", | ||
"description": "Static typed html dom builder.", | ||
"version": "0.0.18", | ||
"description": "Static typed dom component builder.", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/falsandtru/typed-dom", |
@@ -5,2 +5,3 @@ # typed-dom | ||
Static typed dom component builder. | ||
Enhance dom manipulability via static typings of TypeScript. | ||
@@ -24,3 +25,3 @@ | ||
assert(component.children.content.element.outerHTML === '<ul><li>item</li><li>item</li></ul>'); | ||
assert(component.children.content.children[0].content === 'item'); | ||
assert(component.children.content.children[0].children === 'item'); | ||
``` |
@@ -132,15 +132,11 @@ import { TypedHTML as ITypedHTML, TypedHTMLContents } from 'typed-dom'; | ||
] | ||
.reduce((obj, tag) => { | ||
.reduce((obj, tag) => ( | ||
obj[tag] = | ||
<T extends TypedHTMLContents<HTMLElement>> | ||
(attrs: { [name: string]: string; }, children: T, factory?: () => HTMLElement) | ||
: TypedHTML<string, HTMLElement, T> => { | ||
if (!children || typeof children === 'function') { | ||
factory = <any>children; | ||
children = <any>attrs; | ||
attrs = {}; | ||
} | ||
return build(factory || (() => document.createElement(tag)), attrs, children); | ||
} | ||
return obj; | ||
}, <TypedHTML<string, HTMLElement, TypedHTMLContents<HTMLElement>>>{}); | ||
(attrs?: { [name: string]: string; }, children?: T, factory?: () => HTMLElement) | ||
: TypedHTML<string, HTMLElement, T> => | ||
!attrs || !children || typeof children === 'function' | ||
? build(<any>children || (() => document.createElement(tag)), {}, <T><any>attrs) | ||
: build(factory || (() => document.createElement(tag)), attrs, children), | ||
obj | ||
), <TypedHTML<string, HTMLElement, TypedHTMLContents<HTMLElement>>>{}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42792
26
1105