typed-dom
Advanced tools
Comparing version 0.0.62 to 0.0.63
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.62 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
/*! typed-dom v0.0.63 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require = function e(t, n, r) { | ||
@@ -83,3 +83,3 @@ function s(o, u) { | ||
this.children_ = children_; | ||
this.type = this.children_ === void 0 ? ElChildrenType.Void : typeof this.children_ === 'string' ? ElChildrenType.Text : Array.isArray(this.children_) ? ElChildrenType.Collection : ElChildrenType.Struct; | ||
this.type = this.children_ === undefined ? ElChildrenType.Void : typeof this.children_ === 'string' ? ElChildrenType.Text : Array.isArray(this.children_) ? ElChildrenType.Collection : ElChildrenType.Struct; | ||
this.tag; | ||
@@ -459,5 +459,5 @@ void throwErrorIfNotUsable(this); | ||
return document.createElement(tag); | ||
}), void 0); | ||
}), undefined); | ||
case 'function': | ||
return new builder_1.El(define(tag, attrs), void 0); | ||
return new builder_1.El(define(tag, attrs), undefined); | ||
case 'string': | ||
@@ -472,4 +472,4 @@ return new builder_1.El(define(tag, children || function () { | ||
return Object.keys(attrs).slice(-1).every(function (key) { | ||
return key === void 0 || typeof attrs[key] === 'object'; | ||
}) ? new builder_1.El(define(tag, factory), attrs) : new builder_1.El(define(tag, factory, attrs), children === factory ? void 0 : children); | ||
return key === undefined || typeof attrs[key] === 'object'; | ||
}) ? new builder_1.El(define(tag, factory), attrs) : new builder_1.El(define(tag, factory, attrs), children === factory ? undefined : children); | ||
default: | ||
@@ -476,0 +476,0 @@ throw new TypeError('TypedDOM: Invalid arguments: [' + attrs + ', ' + children + ', ' + factory + ']'); |
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.62 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
/*! typed-dom v0.0.63 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require=function e(t,r,n){function i(c,a){if(!r[c]){if(!t[c]){var u="function"==typeof require&&require;if(!a&&u)return u(c,!0);if(o)return o(c,!0);var l=new Error("Cannot find module '"+c+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[c]={exports:{}};t[c][0].call(f.exports,function(e){var r=t[c][1][e];return i(r||e)},f,f.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";function n(e){var t=e.element;if(null!==t.parentElement&&u.has(t.parentElement))throw new Error("TypedDOM: Cannot add an element used in another typed dom.")}var i=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},o=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)c.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return c},c=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(o(arguments[t]));return e};Object.defineProperty(r,"__esModule",{value:!0});var a;!function(e){e.Void="void",e.Text="text",e.Collection="collection",e.Struct="struct"}(a||(a={}));var u=new WeakSet,l=function(){function e(e,t){function r(){for(;e.childNodes.length>0;)e.removeChild(e.firstChild)}function l(e,t){function r(e,t){e.innerHTML=e.innerHTML.replace(/^\s*\$scope(?!\w)/gm,"#"+t),c(e.querySelectorAll("*")).forEach(function(e){return void e.remove()})}if(e.match(/^[\w\-]+$/))return void Object.values(t).map(function(e){return e.element}).forEach(function(t){return t instanceof HTMLStyleElement&&void r(t,e)})}switch(this.element_=e,this.children_=t,this.type=void 0===this.children_?a.Void:"string"==typeof this.children_?a.Text:Array.isArray(this.children_)?a.Collection:a.Struct,this.tag,n(this),u.add(e),this.type){case a.Void:return;case a.Text:return r(),this.children_=document.createTextNode(""),this.element_.appendChild(this.children_),void(this.children=t);case a.Collection:return r(),this.children_=[],this.children=t,void l(this.element_.id,this.children_);case a.Struct:return r(),this.children_=function(e,t){return Object.defineProperties(t,Object.entries(t).reduce(function(t,r){var i=o(r,2),c=i[0],a=i[1];return n(a),e.appendChild(a.element),t[c]={configurable:!0,enumerable:!0,get:function(){return a},set:function(t){var r=a;t!==r&&(t.element_.parentElement===e||n(t),a=t,e.replaceChild(t.element,r.element))}},t},{}))}(this.element_,i({},t)),void l(this.element_.id,this.children_)}}return Object.defineProperty(e.prototype,"element",{get:function(){return this.element_},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){switch(this.type){case a.Text:return this.children_.data;default:return this.children_}},set:function(e){var t=this;switch(this.type){case a.Void:return;case a.Text:return void(this.children_.data=e);case a.Collection:return this.children_.reduce(function(e,t){var r=e.indexOf(t);return r>-1?e:(e.splice(r,1),t.element.remove(),e)},c(e)),this.children_=[],e.forEach(function(e,r){e.element_.parentElement===t.element_||n(e),t.children_[r]=e,t.element_.appendChild(e.element)}),void Object.freeze(this.children_);case a.Struct:return void Object.keys(this.children_).forEach(function(r){return t.children_[r]=e[r]})}},enumerable:!0,configurable:!0}),e}();r.El=l},{}],3:[function(e,t,r){"use strict";function n(e,t,r){var n=t();if(e!==n.tagName.toLowerCase())throw new Error('TypedDOM: Tag name must be "'+e+'" but "'+n.tagName.toLowerCase()+'".');return r?(Object.keys(r).forEach(function(e){return void n.setAttribute(e,r[e])}),n):n}var i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)c.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return c},o=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(i(arguments[t]));return e};Object.defineProperty(r,"__esModule",{value:!0});var c=e("./builder");r.tags={a:0,applet:0,area:0,audio:0,base:0,basefont:0,blockquote:0,body:0,br:0,button:0,canvas:0,caption:0,col:0,colgroup:0,data:0,datalist:0,del:0,dir:0,div:0,dl:0,embed:0,fieldset:0,font:0,form:0,frame:0,frameset:0,h1:0,h2:0,h3:0,h4:0,h5:0,h6:0,head:0,hr:0,html:0,iframe:0,img:0,input:0,ins:0,isindex:0,label:0,legend:0,li:0,link:0,listing:0,map:0,marquee:0,menu:0,meta:0,meter:0,nextid:0,object:0,ol:0,optgroup:0,option:0,output:0,p:0,param:0,picture:0,pre:0,progress:0,q:0,script:0,select:0,source:0,span:0,style:0,table:0,tbody:0,td:0,template:0,textarea:0,tfoot:0,th:0,thead:0,time:0,title:0,tr:0,track:0,ul:0,video:0,"x-ms-webview":0,xmp:0,abbr:0,acronym:0,address:0,article:0,aside:0,b:0,bdo:0,big:0,center:0,circle:0,cite:0,clippath:0,code:0,dd:0,defs:0,desc:0,dfn:0,dt:0,ellipse:0,em:0,feblend:0,fecolormatrix:0,fecomponenttransfer:0,fecomposite:0,feconvolvematrix:0,fediffuselighting:0,fedisplacementmap:0,fedistantlight:0,feflood:0,fefunca:0,fefuncb:0,fefuncg:0,fefuncr:0,fegaussianblur:0,feimage:0,femerge:0,femergenode:0,femorphology:0,feoffset:0,fepointlight:0,fespecularlighting:0,fespotlight:0,fetile:0,feturbulence:0,figcaption:0,figure:0,filter:0,footer:0,foreignobject:0,g:0,header:0,hgroup:0,i:0,image:0,kbd:0,keygen:0,line:0,lineargradient:0,mark:0,marker:0,mask:0,metadata:0,nav:0,nobr:0,noframes:0,noscript:0,path:0,pattern:0,plaintext:0,polygon:0,polyline:0,radialgradient:0,rect:0,rt:0,ruby:0,s:0,samp:0,section:0,small:0,stop:0,strike:0,strong:0,sub:0,sup:0,svg:0,switch:0,symbol:0,text:0,textpath:0,tspan:0,tt:0,u:0,use:0,var:0,view:0,wbr:0},r.TypedHTML=o(Object.keys(r.tags),["create","any"]).reduce(function(e,t){return e[t]="create"===t?function(e,t,n,i){return void 0===t&&(t=function(){return document.createElement(e)}),void 0===n&&(n=function(){return document.createElement(e)}),void 0===i&&(i=function(){return document.createElement(e)}),r.TypedHTML.any(t,n,i,e)}:function(e,r,i,o){switch(void 0===o&&(o=t),o="any"===t?o:t,typeof e){case"undefined":return new c.El(n(o,function(){return document.createElement(o)}),void 0);case"function":return new c.El(n(o,e),void 0);case"string":return new c.El(n(o,r||function(){return document.createElement(o)}),e);case"object":return i="function"==typeof r?r:i||function(){return document.createElement(o)},Object.keys(e).slice(-1).every(function(t){return void 0===t||"object"==typeof e[t]})?new c.El(n(o,i),e):new c.El(n(o,i,e),r===i?void 0:r);default:throw new TypeError("TypedDOM: Invalid arguments: ["+e+", "+r+", "+i+"]")}},e},{})},{"./builder":2}],4:[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":3,"./util/dom":5}],5:[function(e,t,r){"use strict";function n(e,t,r,n,a){return void 0===n&&(n=!1),void 0===a&&(a={}),"string"==typeof r?o(e,t,r,n,c({},"boolean"==typeof a?{capture:a}:a,{once:!0})):i(e,t,r,c({},"boolean"==typeof n?{capture:n}:n,{once:!0}))}function i(e,t,n,i){function o(e){"object"==typeof i&&(i.passive&&(e.preventDefault=l.noop),i.once&&a()),r.currentTargets.set(e,e.currentTarget),n(e)}function c(e){return f?e:"boolean"==typeof e?e:!!e.capture}void 0===i&&(i=!1),e.addEventListener(t,o,c(i));var a=function(){return a=l.noop,void e.removeEventListener(t,o,c(i))};return function(){return void a()}}function o(e,t,r,o,a){return void 0===a&&(a={}),i(e instanceof Document?e.documentElement:e,r,function(i){var c=i.target.closest(t);c&&u(e.querySelectorAll(t)).filter(function(e){return e===c}).forEach(function(e){return void n(e,r,function(e){o(e)},a)})},c({},a,{capture:!0}))}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},a=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)c.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return c},u=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e};Object.defineProperty(r,"__esModule",{value:!0});var l=e("./noop");r.currentTargets=new WeakMap,r.listen=function(e,t,r,n,c){return void 0===n&&(n=!1),void 0===c&&(c={}),"string"==typeof r?o(e,t,r,n,c):i(e,t,r,n)},r.once=n,r.bind=i,r.delegate=o;var f=!1;try{document.createElement("div").addEventListener("test",function(){},{get capture(){return f=!0}})}catch(e){}},{"./noop":6}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.noop=function(){}},{}],"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"]); |
{ | ||
"name": "typed-dom", | ||
"version": "0.0.62", | ||
"version": "0.0.63", | ||
"description": "Static typed dom component builder.", | ||
@@ -33,3 +33,3 @@ "private": false, | ||
"devDependencies": { | ||
"@types/mocha": "^2.2.43", | ||
"@types/mocha": "^2.2.44", | ||
"@types/power-assert": "1.4.29", | ||
@@ -61,5 +61,5 @@ "browserify": "^14.5.0", | ||
"run-sequence": "^2.2.0", | ||
"spica": "0.0.115", | ||
"spica": "0.0.117", | ||
"tsify": "^3.0.3", | ||
"typescript": "2.7.0-dev.20171025", | ||
"typescript": "2.7.0-dev.20171026", | ||
"vinyl-buffer": "^1.0.0", | ||
@@ -66,0 +66,0 @@ "vinyl-source-stream": "^1.1.0", |
@@ -110,3 +110,3 @@ type ElChildrenType = | ||
private readonly type: ElChildrenType = | ||
this.children_ === void 0 | ||
this.children_ === undefined | ||
? ElChildrenType.Void | ||
@@ -113,0 +113,0 @@ : typeof this.children_ === 'string' |
@@ -223,5 +223,5 @@ import { El, ElChildren } from './builder'; | ||
case 'undefined': | ||
return new El(define(tag, () => document.createElement(tag)), void 0 as never); | ||
return new El(define(tag, () => document.createElement(tag)), undefined as never); | ||
case 'function': | ||
return new El(define(tag, attrs as any), void 0 as never); | ||
return new El(define(tag, attrs as any), undefined as never); | ||
case 'string': | ||
@@ -233,5 +233,5 @@ return new El(define(tag, children as any || (() => document.createElement(tag))), attrs as never); | ||
: factory || (() => document.createElement(tag)); | ||
return Object.keys(attrs!).slice(-1).every(key => key === void 0 || typeof attrs![key] === 'object') | ||
return Object.keys(attrs!).slice(-1).every(key => key === undefined || typeof attrs![key] === 'object') | ||
? new El(define(tag, factory), attrs as any) | ||
: new El(define(tag, factory, attrs!), children as any === factory ? void 0 : children) | ||
: new El(define(tag, factory, attrs!), children as any === factory ? undefined : children) | ||
default: | ||
@@ -238,0 +238,0 @@ throw new TypeError(`TypedDOM: Invalid arguments: [${attrs}, ${children}, ${factory}]`); |
@@ -12,3 +12,3 @@ import TypedHTML from '../../index'; | ||
assert(dom.element.outerHTML === '<p></p>'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
}); | ||
@@ -23,3 +23,3 @@ | ||
assert(dom.element.id === 'test'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
assert.throws(() => TypedHTML.p(() => TypedHTML.div([TypedHTML.p()]).children[0].element)); | ||
@@ -200,3 +200,3 @@ }); | ||
assert(dom.element.getAttribute('class') === 'test'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
}); | ||
@@ -213,3 +213,3 @@ | ||
assert(dom.element.className === 'test'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
}); | ||
@@ -277,3 +277,3 @@ | ||
assert(dom.element.outerHTML === '<any></any>'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
}); | ||
@@ -285,3 +285,3 @@ | ||
assert(dom.element.outerHTML === '<any></any>'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
}); | ||
@@ -308,3 +308,3 @@ | ||
assert(dom.element.id === 'test'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
}); | ||
@@ -321,3 +321,3 @@ | ||
assert(dom.element.className === 'test'); | ||
assert(dom.children === void 0); | ||
assert(dom.children === undefined); | ||
}); | ||
@@ -371,3 +371,3 @@ | ||
assert(TypedHTML.p(() => TypedHTML.p('a').element).element.innerHTML === 'a'); | ||
assert(TypedHTML.p(() => TypedHTML.p('a').element).children === void 0); | ||
assert(TypedHTML.p(() => TypedHTML.p('a').element).children === undefined); | ||
assert(TypedHTML.p('', () => TypedHTML.p('a').element).element.innerHTML === ''); | ||
@@ -374,0 +374,0 @@ assert(TypedHTML.p('', () => TypedHTML.p('a').element).children === ''); |
Sorry, the diff of this file is too big to display
455399