typed-dom
Advanced tools
Comparing version 0.0.28 to 0.0.29
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.28 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
/*! typed-dom v0.0.29 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require = function e(t, n, r) { | ||
@@ -34,8 +34,2 @@ function s(o, u) { | ||
function (require, module, exports) { | ||
arguments[4][1][0].apply(exports, arguments); | ||
}, | ||
{ 'dup': 1 } | ||
], | ||
3: [ | ||
function (require, module, exports) { | ||
'use strict'; | ||
@@ -59,2 +53,3 @@ var __assign = this && this.__assign || Object.assign || function (t) { | ||
this.structkeys = this.mode === 'struct' ? Object.keys(this.children_) : []; | ||
this.tag; | ||
if (children_ === void 0) | ||
@@ -189,3 +184,3 @@ return; | ||
], | ||
4: [ | ||
3: [ | ||
function (require, module, exports) { | ||
@@ -339,5 +334,5 @@ 'use strict'; | ||
}, | ||
{ './builder': 3 } | ||
{ './builder': 2 } | ||
], | ||
5: [ | ||
4: [ | ||
function (require, module, exports) { | ||
@@ -354,10 +349,12 @@ 'use strict'; | ||
exports.TypedHTML = html_1.TypedHTML; | ||
__export(require('./util/unique')); | ||
__export(require('./util/dom')); | ||
}, | ||
{ | ||
'./dom/html': 4, | ||
'./util/dom': 6 | ||
'./dom/html': 3, | ||
'./util/dom': 5, | ||
'./util/unique': 7 | ||
} | ||
], | ||
6: [ | ||
5: [ | ||
function (require, module, exports) { | ||
@@ -440,5 +437,5 @@ 'use strict'; | ||
}, | ||
{ './noop': 7 } | ||
{ './noop': 6 } | ||
], | ||
7: [ | ||
6: [ | ||
function (require, module, exports) { | ||
@@ -454,2 +451,14 @@ 'use strict'; | ||
], | ||
7: [ | ||
function (require, module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var count = 0; | ||
function unique() { | ||
return ('' + ('0'.repeat(9) + ++count)).slice(1); | ||
} | ||
exports.unique = unique; | ||
}, | ||
{} | ||
], | ||
'typed-dom': [ | ||
@@ -468,8 +477,7 @@ function (require, module, exports) { | ||
}, | ||
{ './src/export': 5 } | ||
{ './src/export': 4 } | ||
] | ||
}, {}, [ | ||
1, | ||
2, | ||
'typed-dom' | ||
]); |
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.28 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */ | ||
require=function e(t,r,n){function i(c,u){if(!r[c]){if(!t[c]){var s="function"==typeof require&&require;if(!u&&s)return s(c,!0);if(o)return o(c,!0);var a=new Error("Cannot find module '"+c+"'");throw a.code="MODULE_NOT_FOUND",a}var d=r[c]={exports:{}};t[c][0].call(d.exports,function(e){var r=t[c][1][e];return i(r||e)},d,d.exports,e,t,r,n)}return r[c].exports}for(var o="function"==typeof require&&require,c=0;c<n.length;c++)i(n[c]);return i}({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";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e};Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){function r(t){e.id.match(/^[\w\-]+$/)&&(t.innerHTML=t.innerHTML.replace(/^\s*\$scope(?!\w)/gm,"#"+e.id),Array.from(t.querySelectorAll("*")).forEach(function(e){return void e.remove()}))}var i=this;if(this.element_=e,this.children_=t,this.mode=void 0===this.children_?"empty":"string"==typeof this.children_?"text":Array.isArray(this.children_)?"collection":"struct",this.structkeys="struct"===this.mode?Object.keys(this.children_):[],void 0!==t)switch(this.mode){case"empty":return;case"text":return this.children_=document.createTextNode(""),this.element_.appendChild(this.children_),void(this.children=t);case"collection":return e.id&&t.forEach(function(e){var t=e.element;return t instanceof HTMLStyleElement&&void r(t)}),this.children_=Object.freeze([]),void(this.children=t);case"struct":return e.id&&Object.keys(t).map(function(e){return t[e]}).forEach(function(e){var t=e.element;return t instanceof HTMLStyleElement&&void r(t)}),this.children_=this.observe(n({},t)),void this.structkeys.forEach(function(e){return void i.element_.appendChild(t[e].element)})}}return Object.defineProperty(e.prototype,"element",{get:function(){return this.element_},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){switch(this.mode){case"text":return this.children_.data;default:return this.children_}},set:function(e){var t=this;switch(this.mode){case"empty":return;case"text":if(e===this.children_.data)return;return void(this.children_.data=e);case"collection":if(e===this.children_)return;if(!Object.isFrozen(this.children_))throw new Error("TypedHTMLElement collections cannot be updated recursively.");return e.reduce(function(e,t){var r=e.indexOf(t);return-1===r?e:(e.splice(r,1),e)},this.children_.slice()).forEach(function(e){return void e.element.remove()}),this.children_=[],e.forEach(function(e,r){return t.children_[r]=e,void t.element_.appendChild(e.element)}),void Object.freeze(this.children_);case"struct":if(e===this.children_)return;return void this.structkeys.forEach(function(r){return t.children_[r]=e[r]})}},enumerable:!0,configurable:!0}),e.prototype.observe=function(e){var t=this;return Object.defineProperties(e,this.structkeys.reduce(function(r,n){var i=e[n];return r[n]={configurable:!0,enumerable:!0,get:function(){return i},set:function(e){var r=i;e!==r&&(i=e,t.element_.replaceChild(e.element,r.element))}},r},{}))},e}();r.TypedHTMLElement=i},{}],4:[function(e,t,r){"use strict";function n(e,t){return Object.keys(e).forEach(function(r){return void t.setAttribute(r,e[r]||"")}),t}Object.defineProperty(r,"__esModule",{value:!0});var i=e("./builder");r.TypedHTML=["a","applet","area","audio","base","basefont","blockquote","body","br","button","canvas","caption","col","colgroup","data","datalist","del","dir","div","dl","embed","fieldset","font","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","hr","html","iframe","img","input","ins","isindex","label","legend","li","link","listing","map","marquee","menu","meta","meter","nextid","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","script","select","source","span","style","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","video","x-ms-webview","xmp","abbr","acronym","address","article","aside","b","bdo","big","center","cite","code","dd","dfn","dt","em","figcaption","figure","footer","header","hgroup","i","kbd","keygen","mark","nav","nobr","noframes","noscript","plaintext","rt","ruby","s","samp","section","small","strike","strong","sub","sup","tt","u","var","wbr","custom"].reduce(function(e,t){return e[t]=function(e,r,o){return e&&r&&"function"!=typeof r?new i.TypedHTMLElement(n(e,(o||function(){return document.createElement(t)})()),r):new i.TypedHTMLElement((r||function(){return document.createElement(t)})(),e)},e},{})},{"./builder":3}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./dom/html");r.default=n.TypedHTML,r.TypedHTML=n.TypedHTML,function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(e("./util/dom"))},{"./dom/html":4,"./util/dom":6}],6:[function(e,t,r){"use strict";function n(e,t,r,n){function i(e){"object"==typeof n&&n.passive&&(e.preventDefault=s.noop),r(e)}void 0===n&&(n=!1),e.addEventListener(t,i,c(n));var o=function(){return o=s.noop,void e.removeEventListener(t,i,c(n))};return function(){return void o()}}function i(e,t,r,i){void 0===i&&(i=!1);var o=n(e,t,function(e){o(),r(e)},i);return function(){return void o()}}function o(e,t,r,o,c){return void 0===c&&(c={}),n(e,r,function(n){var u=n.target.closest(t);u&&Array.from(e.querySelectorAll(t)).filter(function(e){return e===u}).forEach(function(e){return void i(e,r,function(e){o(e)},c)})},u({},c,{capture:!0}))}function c(e){return a?e:"boolean"==typeof e?e:e.capture}var u=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e};Object.defineProperty(r,"__esModule",{value:!0});var s=e("./noop");r.bind=n,r.once=i,r.delegate=o;var a=!1;try{document.createElement("div").addEventListener("test",function(){},{get capture(){return a=!0}})}catch(e){}},{"./noop":7}],7:[function(e,t,r){"use strict";function n(){}Object.defineProperty(r,"__esModule",{value:!0}),r.noop=n},{}],"typed-dom":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(e("./src/export"));var n=e("./src/export");r.default=n.default},{"./src/export":5}]},{},[1,2,"typed-dom"]); | ||
/*! typed-dom v0.0.29 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require=function e(t,r,n){function i(c,u){if(!r[c]){if(!t[c]){var s="function"==typeof require&&require;if(!u&&s)return s(c,!0);if(o)return o(c,!0);var a=new Error("Cannot find module '"+c+"'");throw a.code="MODULE_NOT_FOUND",a}var d=r[c]={exports:{}};t[c][0].call(d.exports,function(e){var r=t[c][1][e];return i(r||e)},d,d.exports,e,t,r,n)}return r[c].exports}for(var o="function"==typeof require&&require,c=0;c<n.length;c++)i(n[c]);return i}({1:[function(e,t,r){},{}],2:[function(e,t,r){"use strict";var n=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e};Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){function r(t){e.id.match(/^[\w\-]+$/)&&(t.innerHTML=t.innerHTML.replace(/^\s*\$scope(?!\w)/gm,"#"+e.id),Array.from(t.querySelectorAll("*")).forEach(function(e){return void e.remove()}))}var i=this;if(this.element_=e,this.children_=t,this.mode=void 0===this.children_?"empty":"string"==typeof this.children_?"text":Array.isArray(this.children_)?"collection":"struct",this.structkeys="struct"===this.mode?Object.keys(this.children_):[],this.tag,void 0!==t)switch(this.mode){case"empty":return;case"text":return this.children_=document.createTextNode(""),this.element_.appendChild(this.children_),void(this.children=t);case"collection":return e.id&&t.forEach(function(e){var t=e.element;return t instanceof HTMLStyleElement&&void r(t)}),this.children_=Object.freeze([]),void(this.children=t);case"struct":return e.id&&Object.keys(t).map(function(e){return t[e]}).forEach(function(e){var t=e.element;return t instanceof HTMLStyleElement&&void r(t)}),this.children_=this.observe(n({},t)),void this.structkeys.forEach(function(e){return void i.element_.appendChild(t[e].element)})}}return Object.defineProperty(e.prototype,"element",{get:function(){return this.element_},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){switch(this.mode){case"text":return this.children_.data;default:return this.children_}},set:function(e){var t=this;switch(this.mode){case"empty":return;case"text":if(e===this.children_.data)return;return void(this.children_.data=e);case"collection":if(e===this.children_)return;if(!Object.isFrozen(this.children_))throw new Error("TypedHTMLElement collections cannot be updated recursively.");return e.reduce(function(e,t){var r=e.indexOf(t);return-1===r?e:(e.splice(r,1),e)},this.children_.slice()).forEach(function(e){return void e.element.remove()}),this.children_=[],e.forEach(function(e,r){return t.children_[r]=e,void t.element_.appendChild(e.element)}),void Object.freeze(this.children_);case"struct":if(e===this.children_)return;return void this.structkeys.forEach(function(r){return t.children_[r]=e[r]})}},enumerable:!0,configurable:!0}),e.prototype.observe=function(e){var t=this;return Object.defineProperties(e,this.structkeys.reduce(function(r,n){var i=e[n];return r[n]={configurable:!0,enumerable:!0,get:function(){return i},set:function(e){var r=i;e!==r&&(i=e,t.element_.replaceChild(e.element,r.element))}},r},{}))},e}();r.TypedHTMLElement=i},{}],3:[function(e,t,r){"use strict";function n(e,t){return Object.keys(e).forEach(function(r){return void t.setAttribute(r,e[r]||"")}),t}Object.defineProperty(r,"__esModule",{value:!0});var i=e("./builder");r.TypedHTML=["a","applet","area","audio","base","basefont","blockquote","body","br","button","canvas","caption","col","colgroup","data","datalist","del","dir","div","dl","embed","fieldset","font","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","hr","html","iframe","img","input","ins","isindex","label","legend","li","link","listing","map","marquee","menu","meta","meter","nextid","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","script","select","source","span","style","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","video","x-ms-webview","xmp","abbr","acronym","address","article","aside","b","bdo","big","center","cite","code","dd","dfn","dt","em","figcaption","figure","footer","header","hgroup","i","kbd","keygen","mark","nav","nobr","noframes","noscript","plaintext","rt","ruby","s","samp","section","small","strike","strong","sub","sup","tt","u","var","wbr","custom"].reduce(function(e,t){return e[t]=function(e,r,o){return e&&r&&"function"!=typeof r?new i.TypedHTMLElement(n(e,(o||function(){return document.createElement(t)})()),r):new i.TypedHTMLElement((r||function(){return document.createElement(t)})(),e)},e},{})},{"./builder":2}],4:[function(e,t,r){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0});var i=e("./dom/html");r.default=i.TypedHTML,r.TypedHTML=i.TypedHTML,n(e("./util/unique")),n(e("./util/dom"))},{"./dom/html":3,"./util/dom":5,"./util/unique":7}],5:[function(e,t,r){"use strict";function n(e,t,r,n){function i(e){"object"==typeof n&&n.passive&&(e.preventDefault=u.noop),r(e)}void 0===n&&(n=!1),e.addEventListener(t,i,o(n));var c=function(){return c=u.noop,void e.removeEventListener(t,i,o(n))};return function(){return void c()}}function i(e,t,r,i){void 0===i&&(i=!1);var o=n(e,t,function(e){o(),r(e)},i);return function(){return void o()}}function o(e){return s?e:"boolean"==typeof e?e:e.capture}var c=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e};Object.defineProperty(r,"__esModule",{value:!0});var u=e("./noop");r.bind=n,r.once=i,r.delegate=function(e,t,r,o,u){return void 0===u&&(u={}),n(e,r,function(n){var c=n.target.closest(t);c&&Array.from(e.querySelectorAll(t)).filter(function(e){return e===c}).forEach(function(e){return void i(e,r,function(e){o(e)},u)})},c({},u,{capture:!0}))};var s=!1;try{document.createElement("div").addEventListener("test",function(){},{get capture(){return s=!0}})}catch(e){}},{"./noop":6}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.noop=function(){}},{}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=0;r.unique=function(){return(""+("0".repeat(9)+ ++n)).slice(1)}},{}],"typed-dom":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(e("./src/export"));var n=e("./src/export");r.default=n.default},{"./src/export":4}]},{},[1,"typed-dom"]); |
@@ -5,4 +5,4 @@ import 'mocha'; | ||
declare global { | ||
export const assert: typeof _assert; | ||
const assert: typeof _assert; | ||
} |
@@ -12,2 +12,3 @@ const gulp = require('gulp'); | ||
const tsify = require('tsify'); | ||
const pump = require('pump'); | ||
const Server = require('karma').Server; | ||
@@ -54,7 +55,5 @@ | ||
let done = true; | ||
return browserify(Object.values(paths).map(p => glob.sync(p)), { | ||
bundleExternal: false, | ||
}) | ||
return browserify(Object.values(paths).map(p => glob.sync(p))) | ||
.require(`./index.ts`, { expose: pkg.name }) | ||
.plugin(tsify, require('./tsconfig.json').compilerOptions) | ||
.plugin(tsify, Object.assign({ global: true }, require('./tsconfig.json').compilerOptions)) | ||
.bundle() | ||
@@ -79,10 +78,12 @@ .on("error", err => done = console.log(err + '')) | ||
gulp.task('ts:dist', function () { | ||
return compile(config.ts.dist.src) | ||
.pipe($.unassert()) | ||
.pipe($.header(config.banner)) | ||
.pipe(gulp.dest(config.ts.dist.dest)) | ||
.pipe($.uglify({ preserveComments: 'license' })) | ||
.pipe($.rename({ extname: '.min.js' })) | ||
.pipe(gulp.dest(config.ts.dist.dest)); | ||
gulp.task('ts:dist', function (done) { | ||
pump([ | ||
compile(config.ts.dist.src), | ||
$.unassert(), | ||
$.header(config.banner), | ||
gulp.dest(config.ts.dist.dest), | ||
$.rename({ extname: '.min.js' }), | ||
$.uglify({ output: { comments: 'all' } }), | ||
gulp.dest(config.ts.dist.dest) | ||
], done); | ||
}); | ||
@@ -129,3 +130,3 @@ | ||
gulp.task('install', function () { | ||
shell('npm i'); | ||
shell('npm i --no-shrinkwrap'); | ||
}); | ||
@@ -135,3 +136,4 @@ | ||
shell('ncu -ua'); | ||
shell('npm i'); | ||
shell('npm i -DE typescript@next --no-shrinkwrap'); | ||
shell('npm i --no-shrinkwrap'); | ||
}); | ||
@@ -153,2 +155,3 @@ | ||
'karma:test', | ||
'ts:dist', | ||
function () { | ||
@@ -155,0 +158,0 @@ done(); |
@@ -9,3 +9,2 @@ module.exports = function (config) { | ||
{ pattern: 'node_modules/power-assert/build/power-assert.js', watched: true, served: true, included: true }, | ||
{ pattern: 'node_modules/spica/dist/spica.js', watched: true, served: true, included: true }, | ||
{ pattern: 'dist/*.js', watched: true, served: true, included: true } | ||
@@ -12,0 +11,0 @@ ], |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"description": "Static typed dom component builder.", | ||
@@ -20,3 +20,2 @@ "private": false, | ||
], | ||
"types": "./index.d.ts", | ||
"main": "./dist/typed-dom.js", | ||
@@ -38,14 +37,14 @@ "files": [ | ||
"@types/power-assert": "1.4.29", | ||
"browserify": "^14.3.0", | ||
"del": "^2.2.2", | ||
"browserify": "^14.4.0", | ||
"del": "^3.0.0", | ||
"extend": "^3.0.1", | ||
"gulp": "^3.9.1", | ||
"gulp-header": "^1.8.8", | ||
"gulp-header": "^1.8.9", | ||
"gulp-load-plugins": "^1.5.0", | ||
"gulp-mocha": "^4.3.1", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-uglify": "^2.1.2", | ||
"gulp-uglify": "^3.0.0", | ||
"gulp-unassert": "^1.0.1", | ||
"karma": "1.7.0", | ||
"karma-chrome-launcher": "^2.1.1", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.1", | ||
@@ -58,9 +57,10 @@ "karma-coveralls": "^1.1.2", | ||
"karma-mocha": "^1.3.0", | ||
"mocha": "^3.4.1", | ||
"npm-check-updates": "^2.11.1", | ||
"power-assert": "^1.4.2", | ||
"run-sequence": "^1.2.2", | ||
"spica": "0.0.66", | ||
"mocha": "^3.4.2", | ||
"npm-check-updates": "^2.12.1", | ||
"power-assert": "^1.4.4", | ||
"pump": "^1.0.2", | ||
"run-sequence": "^2.0.0", | ||
"spica": "0.0.94", | ||
"tsify": "^3.0.1", | ||
"typescript": "2.4.0-dev.20170517", | ||
"typescript": "2.4.0", | ||
"vinyl-buffer": "^1.0.0", | ||
@@ -70,7 +70,7 @@ "vinyl-source-stream": "^1.1.0" | ||
"scripts": { | ||
"test": "npm i && gulp test", | ||
"test": "gulp test", | ||
"ci": "gulp ci" | ||
}, | ||
"author": "falsandtru", | ||
"license": "MIT" | ||
"license": "(Apache-2.0 AND MPL-2.0)" | ||
} |
@@ -9,6 +9,2 @@ # typed-dom | ||
## API | ||
[index.d.ts](index.d.ts) | ||
## Usage | ||
@@ -102,3 +98,3 @@ | ||
```ts | ||
import TypedHTML from 'typed-dom'; | ||
import TypedHTML, { unique } from 'typed-dom'; | ||
@@ -109,3 +105,3 @@ class MicroComponent { | ||
} | ||
private readonly dom = TypedHTML.div({ id: `${this.parent.id}-list-${Date.now()}-${Math.random() * 1e9 | 0}` }, { | ||
private readonly dom = TypedHTML.div({ id: `${this.parent.id}-list-${unique()}` }, { | ||
style: TypedHTML.style(`$scope ul { width: 100px; }`), | ||
@@ -112,0 +108,0 @@ content: TypedHTML.ul([ |
@@ -1,3 +0,1 @@ | ||
import { TypedHTMLElement as ITypedHTMLElement } from '../../'; | ||
export type TypedHTMLElementChildren | ||
@@ -12,9 +10,3 @@ = TypedHTMLElementChildren.Text | ||
} | ||
export interface TypedHTMLElement< | ||
T extends string, | ||
E extends HTMLElement, | ||
C extends TypedHTMLElementChildren | ||
> | ||
extends ITypedHTMLElement<T, E, C> { | ||
} | ||
export class TypedHTMLElement< | ||
@@ -24,4 +16,4 @@ T extends string, | ||
C extends TypedHTMLElementChildren | ||
> | ||
implements ITypedHTMLElement<T, E, C> { | ||
> { | ||
private tag: T; | ||
constructor( | ||
@@ -31,2 +23,3 @@ private readonly element_: E, | ||
) { | ||
this.tag; | ||
if (children_ === void 0) return; | ||
@@ -143,3 +136,3 @@ switch (this.mode) { | ||
enumerable: true, | ||
get: (): ITypedHTMLElement<string, HTMLElement, any> => { | ||
get: (): TypedHTMLElement<string, HTMLElement, any> => { | ||
return current; | ||
@@ -146,0 +139,0 @@ }, |
@@ -1,6 +0,65 @@ | ||
import { TypedHTML as ITypedHTML } from '../../'; | ||
import { TypedHTMLElement, TypedHTMLElementChildren } from './builder'; | ||
export const TypedHTML: typeof ITypedHTML = [ | ||
interface TypedHTMLElementBuilder<T extends string, E extends HTMLElement> { | ||
(): TypedHTMLElement<T, E, never>; | ||
<C extends TypedHTMLElementChildren> | ||
(children: C, factory?: () => E): TypedHTMLElement<T, E, C>; | ||
<C extends TypedHTMLElementChildren> | ||
(attrs: { [name: string]: string; }, children: C, factory?: () => E): TypedHTMLElement<T, E, C>; | ||
} | ||
export const TypedHTML: { | ||
// lib.dom.d.ts | ||
[K in keyof HTMLElementTagNameMap]: TypedHTMLElementBuilder<K, HTMLElementTagNameMap[K]>; | ||
} & { | ||
// other | ||
abbr: TypedHTMLElementBuilder<'abbr', HTMLElement>; | ||
acronym: TypedHTMLElementBuilder<'acronym', HTMLElement>; | ||
address: TypedHTMLElementBuilder<'address', HTMLElement>; | ||
article: TypedHTMLElementBuilder<'article', HTMLElement>; | ||
aside: TypedHTMLElementBuilder<'aside', HTMLElement>; | ||
b: TypedHTMLElementBuilder<'b', HTMLElement>; | ||
bdo: TypedHTMLElementBuilder<'bdo', HTMLElement>; | ||
big: TypedHTMLElementBuilder<'big', HTMLElement>; | ||
center: TypedHTMLElementBuilder<'center', HTMLElement>; | ||
cite: TypedHTMLElementBuilder<'cite', HTMLElement>; | ||
code: TypedHTMLElementBuilder<'code', HTMLElement>; | ||
dd: TypedHTMLElementBuilder<'dd', HTMLElement>; | ||
dfn: TypedHTMLElementBuilder<'dfn', HTMLElement>; | ||
dt: TypedHTMLElementBuilder<'dt', HTMLElement>; | ||
em: TypedHTMLElementBuilder<'em', HTMLElement>; | ||
figcaption: TypedHTMLElementBuilder<'figcaption', HTMLElement>; | ||
figure: TypedHTMLElementBuilder<'figure', HTMLElement>; | ||
footer: TypedHTMLElementBuilder<'footer', HTMLElement>; | ||
header: TypedHTMLElementBuilder<'header', HTMLElement>; | ||
hgroup: TypedHTMLElementBuilder<'hgroup', HTMLElement>; | ||
i: TypedHTMLElementBuilder<'i', HTMLElement>; | ||
kbd: TypedHTMLElementBuilder<'kbd', HTMLElement>; | ||
keygen: TypedHTMLElementBuilder<'keygen', HTMLElement>; | ||
mark: TypedHTMLElementBuilder<'mark', HTMLElement>; | ||
nav: TypedHTMLElementBuilder<'nav', HTMLElement>; | ||
nobr: TypedHTMLElementBuilder<'nobr', HTMLElement>; | ||
noframes: TypedHTMLElementBuilder<'noframes', HTMLElement>; | ||
noscript: TypedHTMLElementBuilder<'noscript', HTMLElement>; | ||
plaintext: TypedHTMLElementBuilder<'plaintext', HTMLElement>; | ||
rt: TypedHTMLElementBuilder<'rt', HTMLElement>; | ||
ruby: TypedHTMLElementBuilder<'ruby', HTMLElement>; | ||
s: TypedHTMLElementBuilder<'s', HTMLElement>; | ||
samp: TypedHTMLElementBuilder<'samp', HTMLElement>; | ||
section: TypedHTMLElementBuilder<'section', HTMLElement>; | ||
small: TypedHTMLElementBuilder<'small', HTMLElement>; | ||
strike: TypedHTMLElementBuilder<'strike', HTMLElement>; | ||
strong: TypedHTMLElementBuilder<'strong', HTMLElement>; | ||
sub: TypedHTMLElementBuilder<'sub', HTMLElement>; | ||
sup: TypedHTMLElementBuilder<'sup', HTMLElement>; | ||
tt: TypedHTMLElementBuilder<'tt', HTMLElement>; | ||
u: TypedHTMLElementBuilder<'u', HTMLElement>; | ||
var: TypedHTMLElementBuilder<'var', HTMLElement>; | ||
wbr: TypedHTMLElementBuilder<'wbr', HTMLElement>; | ||
// custom | ||
custom<T extends string, E extends HTMLElement = HTMLElement, C extends TypedHTMLElementChildren = TypedHTMLElementChildren>(children: C, factory: () => E, tag: T): TypedHTMLElement<T, E, C>; | ||
custom<T extends string, E extends HTMLElement = HTMLElement, C extends TypedHTMLElementChildren = TypedHTMLElementChildren>(attrs: { [name: string]: string; }, children: C, factory: () => E, tag: T): TypedHTMLElement<T, E, C>; | ||
} = [ | ||
// lib.dom.d.ts | ||
"a", | ||
@@ -145,3 +204,3 @@ "applet", | ||
obj | ||
), <typeof ITypedHTML>{}); | ||
), <any>{}); | ||
@@ -148,0 +207,0 @@ function attribute<E extends HTMLElement>(attrs: { [name: string]: string }, element: E): E { |
export { TypedHTML as default, TypedHTML } from './dom/html'; | ||
export * from './util/unique'; | ||
export * from './util/dom'; |
@@ -1,3 +0,3 @@ | ||
import { Sequence } from 'spica'; | ||
import TypedHTML from '../../index'; | ||
import TypedHTML, { unique } from '../../index'; | ||
import { Sequence } from 'spica/sequence'; | ||
@@ -186,2 +186,7 @@ declare const _: { | ||
it('unique', function () { | ||
assert(unique().match(/^0\d{8}$/)); | ||
assert(unique() < unique()); | ||
}); | ||
}); | ||
@@ -194,3 +199,3 @@ | ||
} | ||
private readonly dom = TypedHTML.div({ id: `${this.parent.id}-list-${Date.now()}-${Math.random() * 1e9 | 0}` }, { | ||
private readonly dom = TypedHTML.div({ id: `${this.parent.id}-list-${unique()}` }, { | ||
style: TypedHTML.style(`$scope ul { width: 100px; }`), | ||
@@ -197,0 +202,0 @@ content: TypedHTML.ul([ |
@@ -1,2 +0,2 @@ | ||
import def, { TypedHTML, bind, once, delegate } from '../../index'; | ||
import def, { TypedHTML, unique, bind, once, delegate } from '../../index'; | ||
@@ -18,3 +18,10 @@ describe('Interface: Package', function () { | ||
describe('bind', function () { | ||
describe('unique', function () { | ||
it('unique', function () { | ||
assert(typeof unique === 'function'); | ||
}); | ||
}); | ||
describe('dom', function () { | ||
it('bind', function () { | ||
@@ -24,5 +31,2 @@ assert(typeof bind === 'function'); | ||
}); | ||
describe('once', function () { | ||
it('once', function () { | ||
@@ -32,5 +36,2 @@ assert(typeof once === 'function'); | ||
}); | ||
describe('delegate', function () { | ||
it('delegate', function () { | ||
@@ -37,0 +38,0 @@ assert(typeof delegate === 'function'); |
@@ -23,3 +23,3 @@ { | ||
"rootDir": "./", | ||
"forceConsistentCasingInFileNames": true, | ||
"forceConsistentCasingInFileNames": false, | ||
"removeComments": false | ||
@@ -26,0 +26,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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
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
88593
22
31
3
70
1408
134