typed-dom
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.1 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License (https://opensource.org/licenses/MIT) */ | ||
/*! typed-dom v0.0.2 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License (https://opensource.org/licenses/MIT) */ | ||
define = typeof define === 'function' && define.amd | ||
@@ -934,15 +934,15 @@ ? define | ||
var raw = factory(); | ||
void Object.keys(children).forEach(function (idx) { | ||
return void raw.appendChild(children[idx].raw); | ||
void Object.keys(children).forEach(function (k) { | ||
return void raw.appendChild(children[k].raw); | ||
}); | ||
if (children instanceof Array === false) { | ||
var c_1 = children; | ||
children = Object.keys(children).reduce(function (obj, idx) { | ||
Object.defineProperty(obj, idx, { | ||
children = Object.keys(children).reduce(function (obj, k) { | ||
Object.defineProperty(obj, k, { | ||
get: function () { | ||
return c_1[idx]; | ||
return c_1[k]; | ||
}, | ||
set: function (newElt) { | ||
var oldElt = c_1[idx]; | ||
c_1[idx] = newElt; | ||
var oldElt = c_1[k]; | ||
c_1[k] = newElt; | ||
raw.replaceChild(newElt.raw, oldElt.raw); | ||
@@ -959,10 +959,14 @@ } | ||
}, | ||
set contents(c) { | ||
if (children instanceof Array === false) | ||
throw new TypeError('TypedDOM: Children cannot update when its type is not an array.'); | ||
children = c; | ||
raw.innerHTML = ''; | ||
children.forEach(function (child) { | ||
return raw.appendChild(child.raw); | ||
}); | ||
set contents(cs) { | ||
if (children instanceof Array) { | ||
raw.innerHTML = ''; | ||
void cs.forEach(function (c) { | ||
return void raw.appendChild(c.raw); | ||
}); | ||
} else { | ||
void Object.keys(cs).forEach(function (k) { | ||
return void raw.replaceChild(cs[k].raw, children[k].raw); | ||
}); | ||
} | ||
children = cs; | ||
} | ||
@@ -969,0 +973,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.1 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License (https://opensource.org/licenses/MIT) */ | ||
define="function"==typeof define&&define.amd?define:function(){"use strict";var n="typed-dom",e={};return function t(r,u,o){return o?void o.apply(this,u.map(function(n){switch(n){case"require":return"function"==typeof require?require:void 0;case"exports":return-1===r.indexOf("/")?e[r]="undefined"==typeof exports?self[r]=self[r]||{}:exports:e[r]=e.hasOwnProperty(r)?e[r]:{};default:return".d"===n.slice(-2)&&{}||e.hasOwnProperty(n)&&e[n]||"function"==typeof require&&require(n)||self[n]}})):void t(n,r,u)}}(),define("src/builder",["require","exports"],function(n,e){"use strict";function t(n,e){void 0===e&&(e=[]);var t=n();if(void Object.keys(e).forEach(function(n){return void t.appendChild(e[n].raw)}),e instanceof Array==!1){var r=e;e=Object.keys(e).reduce(function(n,e){return Object.defineProperty(n,e,{get:function(){return r[e]},set:function(n){var u=r[e];r[e]=n,t.replaceChild(n.raw,u.raw)}}),n},{})}return{raw:t,get contents(){return e},set contents(n){if(e instanceof Array==!1)throw new TypeError("TypedDOM: Children cannot update when its type is not an array.");e=n,t.innerHTML="",e.forEach(function(n){return t.appendChild(n.raw)})}}}e.TypedHTML={a:function(n,e){return void 0===e&&(e=function(){return document.createElement("a")}),t(e,n)},abbr:function(n,e){return void 0===e&&(e=function(){return document.createElement("abbr")}),t(e,n)},acronym:function(n,e){return void 0===e&&(e=function(){return document.createElement("acronym")}),t(e,n)},address:function(n,e){return void 0===e&&(e=function(){return document.createElement("address")}),t(e,n)},applet:function(n,e){return void 0===e&&(e=function(){return document.createElement("applet")}),t(e,n)},area:function(n,e){return void 0===e&&(e=function(){return document.createElement("area")}),t(e,n)},audio:function(n,e){return void 0===e&&(e=function(){return document.createElement("audio")}),t(e,n)},b:function(n,e){return void 0===e&&(e=function(){return document.createElement("b")}),t(e,n)},base:function(n,e){return void 0===e&&(e=function(){return document.createElement("base")}),t(e,n)},basefont:function(n,e){return void 0===e&&(e=function(){return document.createElement("basefont")}),t(e,n)},bdo:function(n,e){return void 0===e&&(e=function(){return document.createElement("bdo")}),t(e,n)},big:function(n,e){return void 0===e&&(e=function(){return document.createElement("big")}),t(e,n)},blockquote:function(n,e){return void 0===e&&(e=function(){return document.createElement("blockquote")}),t(e,n)},body:function(n,e){return void 0===e&&(e=function(){return document.createElement("body")}),t(e,n)},br:function(n,e){return void 0===e&&(e=function(){return document.createElement("br")}),t(e,n)},button:function(n,e){return void 0===e&&(e=function(){return document.createElement("button")}),t(e,n)},canvas:function(n,e){return void 0===e&&(e=function(){return document.createElement("canvas")}),t(e,n)},caption:function(n,e){return void 0===e&&(e=function(){return document.createElement("caption")}),t(e,n)},center:function(n,e){return void 0===e&&(e=function(){return document.createElement("center")}),t(e,n)},cite:function(n,e){return void 0===e&&(e=function(){return document.createElement("cite")}),t(e,n)},code:function(n,e){return void 0===e&&(e=function(){return document.createElement("code")}),t(e,n)},col:function(n,e){return void 0===e&&(e=function(){return document.createElement("col")}),t(e,n)},colgroup:function(n,e){return void 0===e&&(e=function(){return document.createElement("colgroup")}),t(e,n)},datalist:function(n,e){return void 0===e&&(e=function(){return document.createElement("datalist")}),t(e,n)},dd:function(n,e){return void 0===e&&(e=function(){return document.createElement("dd")}),t(e,n)},del:function(n,e){return void 0===e&&(e=function(){return document.createElement("del")}),t(e,n)},dfn:function(n,e){return void 0===e&&(e=function(){return document.createElement("dfn")}),t(e,n)},dir:function(n,e){return void 0===e&&(e=function(){return document.createElement("dir")}),t(e,n)},div:function(n,e){return void 0===e&&(e=function(){return document.createElement("div")}),t(e,n)},dl:function(n,e){return void 0===e&&(e=function(){return document.createElement("dl")}),t(e,n)},dt:function(n,e){return void 0===e&&(e=function(){return document.createElement("dt")}),t(e,n)},em:function(n,e){return void 0===e&&(e=function(){return document.createElement("em")}),t(e,n)},embed:function(n,e){return void 0===e&&(e=function(){return document.createElement("embed")}),t(e,n)},fieldset:function(n,e){return void 0===e&&(e=function(){return document.createElement("fieldset")}),t(e,n)},font:function(n,e){return void 0===e&&(e=function(){return document.createElement("font")}),t(e,n)},form:function(n,e){return void 0===e&&(e=function(){return document.createElement("form")}),t(e,n)},frame:function(n,e){return void 0===e&&(e=function(){return document.createElement("frame")}),t(e,n)},frameset:function(n,e){return void 0===e&&(e=function(){return document.createElement("frameset")}),t(e,n)},h1:function(n,e){return void 0===e&&(e=function(){return document.createElement("h1")}),t(e,n)},h2:function(n,e){return void 0===e&&(e=function(){return document.createElement("h2")}),t(e,n)},h3:function(n,e){return void 0===e&&(e=function(){return document.createElement("h3")}),t(e,n)},h4:function(n,e){return void 0===e&&(e=function(){return document.createElement("h4")}),t(e,n)},h5:function(n,e){return void 0===e&&(e=function(){return document.createElement("h5")}),t(e,n)},h6:function(n,e){return void 0===e&&(e=function(){return document.createElement("h6")}),t(e,n)},head:function(n,e){return void 0===e&&(e=function(){return document.createElement("head")}),t(e,n)},hr:function(n,e){return void 0===e&&(e=function(){return document.createElement("hr")}),t(e,n)},html:function(n,e){return void 0===e&&(e=function(){return document.createElement("html")}),t(e,n)},i:function(n,e){return void 0===e&&(e=function(){return document.createElement("i")}),t(e,n)},iframe:function(n,e){return void 0===e&&(e=function(){return document.createElement("iframe")}),t(e,n)},img:function(n,e){return void 0===e&&(e=function(){return document.createElement("img")}),t(e,n)},input:function(n,e){return void 0===e&&(e=function(){return document.createElement("input")}),t(e,n)},ins:function(n,e){return void 0===e&&(e=function(){return document.createElement("ins")}),t(e,n)},isindex:function(n,e){return void 0===e&&(e=function(){return document.createElement("isindex")}),t(e,n)},kbd:function(n,e){return void 0===e&&(e=function(){return document.createElement("kbd")}),t(e,n)},keygen:function(n,e){return void 0===e&&(e=function(){return document.createElement("keygen")}),t(e,n)},label:function(n,e){return void 0===e&&(e=function(){return document.createElement("label")}),t(e,n)},legend:function(n,e){return void 0===e&&(e=function(){return document.createElement("legend")}),t(e,n)},li:function(n,e){return void 0===e&&(e=function(){return document.createElement("li")}),t(e,n)},link:function(n,e){return void 0===e&&(e=function(){return document.createElement("link")}),t(e,n)},listing:function(n,e){return void 0===e&&(e=function(){return document.createElement("listing")}),t(e,n)},map:function(n,e){return void 0===e&&(e=function(){return document.createElement("map")}),t(e,n)},marquee:function(n,e){return void 0===e&&(e=function(){return document.createElement("marquee")}),t(e,n)},menu:function(n,e){return void 0===e&&(e=function(){return document.createElement("menu")}),t(e,n)},meta:function(n,e){return void 0===e&&(e=function(){return document.createElement("meta")}),t(e,n)},nextid:function(n,e){return void 0===e&&(e=function(){return document.createElement("nextid")}),t(e,n)},nobr:function(n,e){return void 0===e&&(e=function(){return document.createElement("nobr")}),t(e,n)},object:function(n,e){return void 0===e&&(e=function(){return document.createElement("object")}),t(e,n)},ol:function(n,e){return void 0===e&&(e=function(){return document.createElement("ol")}),t(e,n)},optgroup:function(n,e){return void 0===e&&(e=function(){return document.createElement("optgroup")}),t(e,n)},option:function(n,e){return void 0===e&&(e=function(){return document.createElement("option")}),t(e,n)},p:function(n,e){return void 0===e&&(e=function(){return document.createElement("p")}),t(e,n)},param:function(n,e){return void 0===e&&(e=function(){return document.createElement("param")}),t(e,n)},picture:function(n,e){return void 0===e&&(e=function(){return document.createElement("picture")}),t(e,n)},plaintext:function(n,e){return void 0===e&&(e=function(){return document.createElement("plaintext")}),t(e,n)},pre:function(n,e){return void 0===e&&(e=function(){return document.createElement("pre")}),t(e,n)},progress:function(n,e){return void 0===e&&(e=function(){return document.createElement("progress")}),t(e,n)},q:function(n,e){return void 0===e&&(e=function(){return document.createElement("q")}),t(e,n)},rt:function(n,e){return void 0===e&&(e=function(){return document.createElement("rt")}),t(e,n)},ruby:function(n,e){return void 0===e&&(e=function(){return document.createElement("ruby")}),t(e,n)},s:function(n,e){return void 0===e&&(e=function(){return document.createElement("s")}),t(e,n)},samp:function(n,e){return void 0===e&&(e=function(){return document.createElement("samp")}),t(e,n)},script:function(n,e){return void 0===e&&(e=function(){return document.createElement("script")}),t(e,n)},select:function(n,e){return void 0===e&&(e=function(){return document.createElement("select")}),t(e,n)},small:function(n,e){return void 0===e&&(e=function(){return document.createElement("small")}),t(e,n)},source:function(n,e){return void 0===e&&(e=function(){return document.createElement("source")}),t(e,n)},span:function(n,e){return void 0===e&&(e=function(){return document.createElement("span")}),t(e,n)},strike:function(n,e){return void 0===e&&(e=function(){return document.createElement("strike")}),t(e,n)},strong:function(n,e){return void 0===e&&(e=function(){return document.createElement("strong")}),t(e,n)},style:function(n,e){return void 0===e&&(e=function(){return document.createElement("style")}),t(e,n)},sub:function(n,e){return void 0===e&&(e=function(){return document.createElement("sub")}),t(e,n)},sup:function(n,e){return void 0===e&&(e=function(){return document.createElement("sup")}),t(e,n)},table:function(n,e){return void 0===e&&(e=function(){return document.createElement("table")}),t(e,n)},tbody:function(n,e){return void 0===e&&(e=function(){return document.createElement("tbody")}),t(e,n)},td:function(n,e){return void 0===e&&(e=function(){return document.createElement("td")}),t(e,n)},textarea:function(n,e){return void 0===e&&(e=function(){return document.createElement("textarea")}),t(e,n)},tfoot:function(n,e){return void 0===e&&(e=function(){return document.createElement("tfoot")}),t(e,n)},th:function(n,e){return void 0===e&&(e=function(){return document.createElement("th")}),t(e,n)},thead:function(n,e){return void 0===e&&(e=function(){return document.createElement("thead")}),t(e,n)},title:function(n,e){return void 0===e&&(e=function(){return document.createElement("title")}),t(e,n)},tr:function(n,e){return void 0===e&&(e=function(){return document.createElement("tr")}),t(e,n)},track:function(n,e){return void 0===e&&(e=function(){return document.createElement("track")}),t(e,n)},tt:function(n,e){return void 0===e&&(e=function(){return document.createElement("tt")}),t(e,n)},u:function(n,e){return void 0===e&&(e=function(){return document.createElement("u")}),t(e,n)},ul:function(n,e){return void 0===e&&(e=function(){return document.createElement("ul")}),t(e,n)},"var":function(n,e){return void 0===e&&(e=function(){return document.createElement("var")}),t(e,n)},video:function(n,e){return void 0===e&&(e=function(){return document.createElement("video")}),t(e,n)},xmp:function(n,e){return void 0===e&&(e=function(){return document.createElement("xmp")}),t(e,n)},article:function(n,e){return void 0===e&&(e=function(){return document.createElement("article")}),t(e,n)},aside:function(n,e){return void 0===e&&(e=function(){return document.createElement("aside")}),t(e,n)},nav:function(n,e){return void 0===e&&(e=function(){return document.createElement("nav")}),t(e,n)},section:function(n,e){return void 0===e&&(e=function(){return document.createElement("section")}),t(e,n)},untyped:function(n,e){return t(e,n)}}}),define("src/export",["require","exports","src/builder"],function(n,e,t){"use strict";e["default"]=t.TypedHTML}),define("typed-dom",["require","exports","src/export","src/export"],function(n,e,t,r){"use strict";function u(n){for(var t in n)e.hasOwnProperty(t)||(e[t]=n[t])}u(t),e["default"]=r["default"]}); | ||
/*! typed-dom v0.0.2 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License (https://opensource.org/licenses/MIT) */ | ||
define="function"==typeof define&&define.amd?define:function(){"use strict";var n="typed-dom",e={};return function t(r,u,o){return o?void o.apply(this,u.map(function(n){switch(n){case"require":return"function"==typeof require?require:void 0;case"exports":return-1===r.indexOf("/")?e[r]="undefined"==typeof exports?self[r]=self[r]||{}:exports:e[r]=e.hasOwnProperty(r)?e[r]:{};default:return".d"===n.slice(-2)&&{}||e.hasOwnProperty(n)&&e[n]||"function"==typeof require&&require(n)||self[n]}})):void t(n,r,u)}}(),define("src/builder",["require","exports"],function(n,e){"use strict";function t(n,e){void 0===e&&(e=[]);var t=n();if(void Object.keys(e).forEach(function(n){return void t.appendChild(e[n].raw)}),e instanceof Array==!1){var r=e;e=Object.keys(e).reduce(function(n,e){return Object.defineProperty(n,e,{get:function(){return r[e]},set:function(n){var u=r[e];r[e]=n,t.replaceChild(n.raw,u.raw)}}),n},{})}return{raw:t,get contents(){return e},set contents(n){e instanceof Array?(t.innerHTML="",void n.forEach(function(n){return void t.appendChild(n.raw)})):void Object.keys(n).forEach(function(r){return void t.replaceChild(n[r].raw,e[r].raw)}),e=n}}}e.TypedHTML={a:function(n,e){return void 0===e&&(e=function(){return document.createElement("a")}),t(e,n)},abbr:function(n,e){return void 0===e&&(e=function(){return document.createElement("abbr")}),t(e,n)},acronym:function(n,e){return void 0===e&&(e=function(){return document.createElement("acronym")}),t(e,n)},address:function(n,e){return void 0===e&&(e=function(){return document.createElement("address")}),t(e,n)},applet:function(n,e){return void 0===e&&(e=function(){return document.createElement("applet")}),t(e,n)},area:function(n,e){return void 0===e&&(e=function(){return document.createElement("area")}),t(e,n)},audio:function(n,e){return void 0===e&&(e=function(){return document.createElement("audio")}),t(e,n)},b:function(n,e){return void 0===e&&(e=function(){return document.createElement("b")}),t(e,n)},base:function(n,e){return void 0===e&&(e=function(){return document.createElement("base")}),t(e,n)},basefont:function(n,e){return void 0===e&&(e=function(){return document.createElement("basefont")}),t(e,n)},bdo:function(n,e){return void 0===e&&(e=function(){return document.createElement("bdo")}),t(e,n)},big:function(n,e){return void 0===e&&(e=function(){return document.createElement("big")}),t(e,n)},blockquote:function(n,e){return void 0===e&&(e=function(){return document.createElement("blockquote")}),t(e,n)},body:function(n,e){return void 0===e&&(e=function(){return document.createElement("body")}),t(e,n)},br:function(n,e){return void 0===e&&(e=function(){return document.createElement("br")}),t(e,n)},button:function(n,e){return void 0===e&&(e=function(){return document.createElement("button")}),t(e,n)},canvas:function(n,e){return void 0===e&&(e=function(){return document.createElement("canvas")}),t(e,n)},caption:function(n,e){return void 0===e&&(e=function(){return document.createElement("caption")}),t(e,n)},center:function(n,e){return void 0===e&&(e=function(){return document.createElement("center")}),t(e,n)},cite:function(n,e){return void 0===e&&(e=function(){return document.createElement("cite")}),t(e,n)},code:function(n,e){return void 0===e&&(e=function(){return document.createElement("code")}),t(e,n)},col:function(n,e){return void 0===e&&(e=function(){return document.createElement("col")}),t(e,n)},colgroup:function(n,e){return void 0===e&&(e=function(){return document.createElement("colgroup")}),t(e,n)},datalist:function(n,e){return void 0===e&&(e=function(){return document.createElement("datalist")}),t(e,n)},dd:function(n,e){return void 0===e&&(e=function(){return document.createElement("dd")}),t(e,n)},del:function(n,e){return void 0===e&&(e=function(){return document.createElement("del")}),t(e,n)},dfn:function(n,e){return void 0===e&&(e=function(){return document.createElement("dfn")}),t(e,n)},dir:function(n,e){return void 0===e&&(e=function(){return document.createElement("dir")}),t(e,n)},div:function(n,e){return void 0===e&&(e=function(){return document.createElement("div")}),t(e,n)},dl:function(n,e){return void 0===e&&(e=function(){return document.createElement("dl")}),t(e,n)},dt:function(n,e){return void 0===e&&(e=function(){return document.createElement("dt")}),t(e,n)},em:function(n,e){return void 0===e&&(e=function(){return document.createElement("em")}),t(e,n)},embed:function(n,e){return void 0===e&&(e=function(){return document.createElement("embed")}),t(e,n)},fieldset:function(n,e){return void 0===e&&(e=function(){return document.createElement("fieldset")}),t(e,n)},font:function(n,e){return void 0===e&&(e=function(){return document.createElement("font")}),t(e,n)},form:function(n,e){return void 0===e&&(e=function(){return document.createElement("form")}),t(e,n)},frame:function(n,e){return void 0===e&&(e=function(){return document.createElement("frame")}),t(e,n)},frameset:function(n,e){return void 0===e&&(e=function(){return document.createElement("frameset")}),t(e,n)},h1:function(n,e){return void 0===e&&(e=function(){return document.createElement("h1")}),t(e,n)},h2:function(n,e){return void 0===e&&(e=function(){return document.createElement("h2")}),t(e,n)},h3:function(n,e){return void 0===e&&(e=function(){return document.createElement("h3")}),t(e,n)},h4:function(n,e){return void 0===e&&(e=function(){return document.createElement("h4")}),t(e,n)},h5:function(n,e){return void 0===e&&(e=function(){return document.createElement("h5")}),t(e,n)},h6:function(n,e){return void 0===e&&(e=function(){return document.createElement("h6")}),t(e,n)},head:function(n,e){return void 0===e&&(e=function(){return document.createElement("head")}),t(e,n)},hr:function(n,e){return void 0===e&&(e=function(){return document.createElement("hr")}),t(e,n)},html:function(n,e){return void 0===e&&(e=function(){return document.createElement("html")}),t(e,n)},i:function(n,e){return void 0===e&&(e=function(){return document.createElement("i")}),t(e,n)},iframe:function(n,e){return void 0===e&&(e=function(){return document.createElement("iframe")}),t(e,n)},img:function(n,e){return void 0===e&&(e=function(){return document.createElement("img")}),t(e,n)},input:function(n,e){return void 0===e&&(e=function(){return document.createElement("input")}),t(e,n)},ins:function(n,e){return void 0===e&&(e=function(){return document.createElement("ins")}),t(e,n)},isindex:function(n,e){return void 0===e&&(e=function(){return document.createElement("isindex")}),t(e,n)},kbd:function(n,e){return void 0===e&&(e=function(){return document.createElement("kbd")}),t(e,n)},keygen:function(n,e){return void 0===e&&(e=function(){return document.createElement("keygen")}),t(e,n)},label:function(n,e){return void 0===e&&(e=function(){return document.createElement("label")}),t(e,n)},legend:function(n,e){return void 0===e&&(e=function(){return document.createElement("legend")}),t(e,n)},li:function(n,e){return void 0===e&&(e=function(){return document.createElement("li")}),t(e,n)},link:function(n,e){return void 0===e&&(e=function(){return document.createElement("link")}),t(e,n)},listing:function(n,e){return void 0===e&&(e=function(){return document.createElement("listing")}),t(e,n)},map:function(n,e){return void 0===e&&(e=function(){return document.createElement("map")}),t(e,n)},marquee:function(n,e){return void 0===e&&(e=function(){return document.createElement("marquee")}),t(e,n)},menu:function(n,e){return void 0===e&&(e=function(){return document.createElement("menu")}),t(e,n)},meta:function(n,e){return void 0===e&&(e=function(){return document.createElement("meta")}),t(e,n)},nextid:function(n,e){return void 0===e&&(e=function(){return document.createElement("nextid")}),t(e,n)},nobr:function(n,e){return void 0===e&&(e=function(){return document.createElement("nobr")}),t(e,n)},object:function(n,e){return void 0===e&&(e=function(){return document.createElement("object")}),t(e,n)},ol:function(n,e){return void 0===e&&(e=function(){return document.createElement("ol")}),t(e,n)},optgroup:function(n,e){return void 0===e&&(e=function(){return document.createElement("optgroup")}),t(e,n)},option:function(n,e){return void 0===e&&(e=function(){return document.createElement("option")}),t(e,n)},p:function(n,e){return void 0===e&&(e=function(){return document.createElement("p")}),t(e,n)},param:function(n,e){return void 0===e&&(e=function(){return document.createElement("param")}),t(e,n)},picture:function(n,e){return void 0===e&&(e=function(){return document.createElement("picture")}),t(e,n)},plaintext:function(n,e){return void 0===e&&(e=function(){return document.createElement("plaintext")}),t(e,n)},pre:function(n,e){return void 0===e&&(e=function(){return document.createElement("pre")}),t(e,n)},progress:function(n,e){return void 0===e&&(e=function(){return document.createElement("progress")}),t(e,n)},q:function(n,e){return void 0===e&&(e=function(){return document.createElement("q")}),t(e,n)},rt:function(n,e){return void 0===e&&(e=function(){return document.createElement("rt")}),t(e,n)},ruby:function(n,e){return void 0===e&&(e=function(){return document.createElement("ruby")}),t(e,n)},s:function(n,e){return void 0===e&&(e=function(){return document.createElement("s")}),t(e,n)},samp:function(n,e){return void 0===e&&(e=function(){return document.createElement("samp")}),t(e,n)},script:function(n,e){return void 0===e&&(e=function(){return document.createElement("script")}),t(e,n)},select:function(n,e){return void 0===e&&(e=function(){return document.createElement("select")}),t(e,n)},small:function(n,e){return void 0===e&&(e=function(){return document.createElement("small")}),t(e,n)},source:function(n,e){return void 0===e&&(e=function(){return document.createElement("source")}),t(e,n)},span:function(n,e){return void 0===e&&(e=function(){return document.createElement("span")}),t(e,n)},strike:function(n,e){return void 0===e&&(e=function(){return document.createElement("strike")}),t(e,n)},strong:function(n,e){return void 0===e&&(e=function(){return document.createElement("strong")}),t(e,n)},style:function(n,e){return void 0===e&&(e=function(){return document.createElement("style")}),t(e,n)},sub:function(n,e){return void 0===e&&(e=function(){return document.createElement("sub")}),t(e,n)},sup:function(n,e){return void 0===e&&(e=function(){return document.createElement("sup")}),t(e,n)},table:function(n,e){return void 0===e&&(e=function(){return document.createElement("table")}),t(e,n)},tbody:function(n,e){return void 0===e&&(e=function(){return document.createElement("tbody")}),t(e,n)},td:function(n,e){return void 0===e&&(e=function(){return document.createElement("td")}),t(e,n)},textarea:function(n,e){return void 0===e&&(e=function(){return document.createElement("textarea")}),t(e,n)},tfoot:function(n,e){return void 0===e&&(e=function(){return document.createElement("tfoot")}),t(e,n)},th:function(n,e){return void 0===e&&(e=function(){return document.createElement("th")}),t(e,n)},thead:function(n,e){return void 0===e&&(e=function(){return document.createElement("thead")}),t(e,n)},title:function(n,e){return void 0===e&&(e=function(){return document.createElement("title")}),t(e,n)},tr:function(n,e){return void 0===e&&(e=function(){return document.createElement("tr")}),t(e,n)},track:function(n,e){return void 0===e&&(e=function(){return document.createElement("track")}),t(e,n)},tt:function(n,e){return void 0===e&&(e=function(){return document.createElement("tt")}),t(e,n)},u:function(n,e){return void 0===e&&(e=function(){return document.createElement("u")}),t(e,n)},ul:function(n,e){return void 0===e&&(e=function(){return document.createElement("ul")}),t(e,n)},"var":function(n,e){return void 0===e&&(e=function(){return document.createElement("var")}),t(e,n)},video:function(n,e){return void 0===e&&(e=function(){return document.createElement("video")}),t(e,n)},xmp:function(n,e){return void 0===e&&(e=function(){return document.createElement("xmp")}),t(e,n)},article:function(n,e){return void 0===e&&(e=function(){return document.createElement("article")}),t(e,n)},aside:function(n,e){return void 0===e&&(e=function(){return document.createElement("aside")}),t(e,n)},nav:function(n,e){return void 0===e&&(e=function(){return document.createElement("nav")}),t(e,n)},section:function(n,e){return void 0===e&&(e=function(){return document.createElement("section")}),t(e,n)},untyped:function(n,e){return t(e,n)}}}),define("src/export",["require","exports","src/builder"],function(n,e,t){"use strict";e["default"]=t.TypedHTML}),define("typed-dom",["require","exports","src/export","src/export"],function(n,e,t,r){"use strict";function u(n){for(var t in n)e.hasOwnProperty(t)||(e[t]=n[t])}u(t),e["default"]=r["default"]}); |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Typed html dom structs.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -681,14 +681,14 @@ import {default as Builder, TypedHTMLElement, TypedHTMLElementChildren} from 'typed-dom'; | ||
void Object.keys(children) | ||
.forEach(idx => void raw.appendChild(children[idx].raw)); | ||
.forEach(k => void raw.appendChild(children[k].raw)); | ||
if (children instanceof Array === false) { | ||
const c = children; | ||
children = Object.keys(children) | ||
.reduce((obj, idx) => { | ||
Object.defineProperty(obj, idx, { | ||
.reduce((obj, k) => { | ||
Object.defineProperty(obj, k, { | ||
get() { | ||
return c[idx]; | ||
return c[k]; | ||
}, | ||
set(newElt) { | ||
const oldElt = c[idx]; | ||
c[idx] = newElt; | ||
const oldElt = c[k]; | ||
c[k] = newElt; | ||
raw.replaceChild(newElt.raw, oldElt.raw); | ||
@@ -705,10 +705,15 @@ } | ||
}, | ||
set contents(c) { | ||
if (children instanceof Array === false) throw new TypeError(`TypedDOM: Children cannot update when its type is not an array.`); | ||
children = c; | ||
raw.innerHTML = ''; | ||
(<any[]><any>children) | ||
.forEach(child => raw.appendChild(child.raw)); | ||
set contents(cs) { | ||
if (children instanceof Array) { | ||
raw.innerHTML = ''; | ||
void (<any[]><any>cs) | ||
.forEach(c => void raw.appendChild(c.raw)); | ||
} | ||
else { | ||
void Object.keys(cs) | ||
.forEach(k => void raw.replaceChild(cs[k].raw, children[k].raw)); | ||
} | ||
children = cs; | ||
} | ||
}; | ||
} |
@@ -11,2 +11,3 @@ import TypedHTML from 'typed-dom'; | ||
assert(struct.raw.nodeName === 'DIV'); | ||
assert(struct.raw.firstChild === struct.contents.title.raw); | ||
assert(struct.contents.title.raw.nodeName === 'H1'); | ||
@@ -19,2 +20,8 @@ assert(struct.contents.list.raw.nodeName === 'UL'); | ||
assert(struct.contents.title.raw.nodeName === 'H2'); | ||
struct.contents = { | ||
title: TypedHTML.h1(), | ||
list: TypedHTML.ul([TypedHTML.li()]) | ||
}; | ||
assert(struct.raw.children[0].nodeName === 'H1'); | ||
assert(struct.contents.title.raw.nodeName === 'H1'); | ||
}); | ||
@@ -21,0 +28,0 @@ |
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
136918
2741