typed-dom
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.15 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
/*! typed-dom v0.0.16 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
require = function e(t, n, r) { | ||
@@ -3,0 +3,0 @@ function s(o, u) { |
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.15 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
/*! typed-dom v0.0.16 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
require=function e(t,r,n){function o(a,c){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!c&&u)return u(a,!0);if(i)return i(a,!0);var d=new Error("Cannot find module '"+a+"'");throw d.code="MODULE_NOT_FOUND",d}var f=r[a]={exports:{}};t[a][0].call(f.exports,function(e){var r=t[a][1][e];return o(r?r:e)},f,f.exports,e,t,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<n.length;a++)o(n[a]);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.raw,n.raw)}}),e},e)}var o=e();if(void 0===r)return Object.freeze({raw:o,contents: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].raw)}),i){case"array":void Object.freeze(r);break;case"object":void n(r)}}return Object.freeze({raw:o,get contents(){switch(i){case"text":return r.data;default:return r}},set contents(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.raw}).forEach(function(e){return void e.remove()}),void e.map(function(e){return e.raw}).forEach(function(e){return void o.appendChild(e)});break;case"object":void Object.keys(e).forEach(function(t){return void o.replaceChild(e[t].raw,r[t].raw)}),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","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"]); |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "Static typed html dom builder.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -7,2 +7,4 @@ # typed-dom | ||
[typed-dom.d.ts](typed-dom.d.ts) | ||
```ts | ||
@@ -25,3 +27,3 @@ import TypedHTML from 'typed-dom'; | ||
assert(component.contents.content.raw.outerHTML === '<ul><li>item</li><li>item</li></ul>'); | ||
assert(component.contents.content[0].contents === 'item'); | ||
assert(component.contents.content.contents[0].content === 'item'); | ||
``` |
@@ -101,5 +101,4 @@ import { Sequence } from 'spica'; | ||
assert(collection.raw.outerHTML === '<ul><li>1</li><li>2</li></ul>'); | ||
assert(collection.contents.length === collection.raw.children.length); | ||
assert(collection.contents[0].raw === collection.raw.children[0]); | ||
assert(collection.contents[1].raw === collection.raw.children[1]); | ||
assert(collection.contents.length === 2); | ||
assert(collection.contents.every(({raw}, i) => raw === collection.raw.children[i])); | ||
}); | ||
@@ -109,25 +108,19 @@ | ||
const collection = TypedHTML.ul([ | ||
TypedHTML.li(), | ||
TypedHTML.li() | ||
TypedHTML.li<string>('1') | ||
]); | ||
collection.contents = [ | ||
TypedHTML.li() | ||
TypedHTML.li('2'), | ||
TypedHTML.li('3') | ||
]; | ||
assert(collection.contents.length === collection.raw.children.length); | ||
assert(collection.contents[0].raw === collection.raw.children[0]); | ||
}); | ||
it('collection contents partial update', function () { | ||
const collection = TypedHTML.ul([ | ||
TypedHTML.li() | ||
]); | ||
// readonly | ||
assert.throws(() => collection.contents[0] = TypedHTML.li()); | ||
assert.throws(() => collection.contents.push(TypedHTML.li())); | ||
assert.throws(() => collection.contents.pop()); | ||
assert.throws(() => collection.contents.length = 0); | ||
assert(collection.raw.outerHTML === '<ul><li>2</li><li>3</li></ul>'); | ||
assert(collection.contents.length === 2); | ||
assert(collection.contents.every(({raw}, i) => raw === collection.raw.children[i])); | ||
collection.contents = [ | ||
TypedHTML.li('4') | ||
]; | ||
assert(collection.raw.outerHTML === '<ul><li>4</li></ul>'); | ||
assert(collection.contents.length === 1); | ||
assert(collection.contents.every(({raw}, i) => raw === collection.raw.children[i])); | ||
// update | ||
// property test | ||
const ss = Array(3).fill(0).map(() => TypedHTML.li()); | ||
@@ -161,4 +154,16 @@ void Sequence.zip( | ||
it('collection contents partial update', function () { | ||
const collection = TypedHTML.ul([ | ||
TypedHTML.li() | ||
]); | ||
assert.throws(() => collection.contents[0] = TypedHTML.li()); | ||
assert.throws(() => collection.contents.push(TypedHTML.li())); | ||
assert.throws(() => collection.contents.pop()); | ||
assert.throws(() => collection.contents.length = 0); | ||
assert(collection.contents.length === 1); | ||
assert(collection.contents.every(({raw}, i) => raw === collection.raw.children[i])); | ||
}); | ||
}); | ||
}); |
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
42368
1109
28