typed-dom
Advanced tools
Comparing version 0.0.56 to 0.0.57
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.56 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
/*! typed-dom v0.0.57 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require = function e(t, n, r) { | ||
@@ -85,4 +85,3 @@ function s(o, u) { | ||
this.tag; | ||
if (memory.has(element_.parentElement)) | ||
throw new Error('TypedDOM: Cannot use a child element of another typed dom.'); | ||
void throwErrorIfNotUsable(this); | ||
void memory.add(element_); | ||
@@ -134,4 +133,3 @@ switch (this.type) { | ||
var current = children[key]; | ||
if (!isOrphan(current)) | ||
throw new Error('TypedDOM: Cannot add a child element used in another typed dom.'); | ||
void throwErrorIfNotUsable(current); | ||
void element.appendChild(current.element); | ||
@@ -148,4 +146,3 @@ descs[key] = { | ||
return; | ||
if (!isOrphan(newChild)) | ||
throw new Error('TypedDOM: Cannot add a child element used in another typed dom.'); | ||
void throwErrorIfNotUsable(newChild); | ||
current = newChild; | ||
@@ -194,4 +191,3 @@ void element.replaceChild(newChild.element, oldChild.element); | ||
void children.forEach(function (child, i) { | ||
if (!isOrphan(child)) | ||
throw new Error('TypedDOM: Cannot add a child element used in another typed dom.'); | ||
void throwErrorIfNotUsable(child); | ||
_this.children_[i] = child; | ||
@@ -215,5 +211,7 @@ void _this.element_.appendChild(child.element); | ||
exports.El = El; | ||
function isOrphan(_a) { | ||
function throwErrorIfNotUsable(_a) { | ||
var element = _a.element; | ||
return element.parentNode === null || element.parentNode instanceof DocumentFragment || !memory.has(element.parentElement); | ||
if (element.parentElement === null || !memory.has(element.parentElement)) | ||
return; | ||
throw new Error('TypedDOM: Cannot add an element used in another typed dom.'); | ||
} | ||
@@ -220,0 +218,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
/*! typed-dom v0.0.56 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
require=function e(t,r,n){function o(c,u){if(!r[c]){if(!t[c]){var a="function"==typeof require&&require;if(!u&&a)return a(c,!0);if(i)return i(c,!0);var d=new Error("Cannot find module '"+c+"'");throw d.code="MODULE_NOT_FOUND",d}var l=r[c]={exports:{}};t[c][0].call(l.exports,function(e){var r=t[c][1][e];return o(r||e)},l,l.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){"use strict";function n(e){var t=e.element;return null===t.parentNode||t.parentNode instanceof DocumentFragment||!a.has(t.parentElement)}var o=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=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 u;!function(e){e.Void="void",e.Text="text",e.Collection="collection",e.Struct="struct"}(u||(u={}));var a=new WeakSet,d=function(){function e(e,t){function r(){for(;e.childNodes.length>0;)e.removeChild(e.firstChild)}function i(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)})}if(this.element_=e,this.children_=t,this.type=void 0===this.children_?u.Void:"string"==typeof this.children_?u.Text:Array.isArray(this.children_)?u.Collection:u.Struct,this.tag,a.has(e.parentElement))throw new Error("TypedDOM: Cannot use a child element of another typed dom.");switch(a.add(e),this.type){case u.Void:return;case u.Text:return r(),this.children_=document.createTextNode(""),this.element_.appendChild(this.children_),void(this.children=t);case u.Collection:return r(),this.children_=[],this.children=t,void i(this.element_.id,this.children_);case u.Struct:return r(),this.children_=function(e,t){return Object.defineProperties(t,Object.keys(t).reduce(function(r,o){var i=t[o];if(!n(i))throw new Error("TypedDOM: Cannot add a child element used in another typed dom.");return e.appendChild(i.element),r[o]={configurable:!0,enumerable:!0,get:function(){return i},set:function(t){var r=i;if(t!==r){if(!n(t))throw new Error("TypedDOM: Cannot add a child element used in another typed dom.");i=t,e.replaceChild(t.element,r.element)}}},r},{}))}(this.element_,o({},t)),void i(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 u.Text:return this.children_.data;default:return this.children_}},set:function(e){var t=this;switch(this.type){case u.Void:return;case u.Text:return void(this.children_.data=e);case u.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){if(!n(e))throw new Error("TypedDOM: Cannot add a child element used in another typed dom.");t.children_[r]=e,t.element_.appendChild(e.element)}),void Object.freeze(this.children_);case u.Struct:return void Object.keys(this.children_).forEach(function(r){return t.children_[r]=e[r]})}},enumerable:!0,configurable:!0}),e}();r.El=d},{}],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}Object.defineProperty(r,"__esModule",{value:!0});var o=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","create","any"].reduce(function(e,t){return e[t]="create"===t?function(e,t,n,o){return void 0===t&&(t=function(){return document.createElement(e)}),void 0===n&&(n=function(){return document.createElement(e)}),void 0===o&&(o=function(){return document.createElement(e)}),r.TypedHTML.any(t,n,o,e)}:function(e,r,i,c){switch(void 0===c&&(c=t),c="any"===t?c:t,typeof e){case"undefined":return new o.El(n(c,function(){return document.createElement(c)}),void 0);case"function":return new o.El(n(c,e),void 0);case"string":return new o.El(n(c,r||function(){return document.createElement(c)}),e);case"object":return i="function"==typeof r?r:i||function(){return document.createElement(c)},Object.keys(e).slice(-1).every(function(t){return void 0===t||"object"==typeof e[t]})?new o.El(n(c,i),e):new o.El(n(c,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,n,o){function c(e){"object"==typeof o&&o.passive&&(e.preventDefault=d.noop),r.currentTargets.set(e,e.currentTarget),n(e)}void 0===o&&(o=!1),e.addEventListener(t,c,i(o));var u=function(){return u=d.noop,void e.removeEventListener(t,c,i(o))};return function(){return void u()}}function o(e,t,r,o){void 0===o&&(o=!1);var i=n(e,t,function(e){i(),r(e)},o);return function(){return void i()}}function i(e){return l?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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},u=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},a=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e};Object.defineProperty(r,"__esModule",{value:!0});var d=e("./noop");r.currentTargets=new WeakMap,r.bind=n,r.once=o,r.delegate=function(e,t,r,i,u){return void 0===u&&(u={}),n(e instanceof Document?e.documentElement:e,r,function(n){var c=n.target.closest(t);c&&a(e.querySelectorAll(t)).filter(function(e){return e===c}).forEach(function(e){return void o(e,r,function(e){i(e)},u)})},c({},u,{capture:!0}))};var l=!1;try{document.createElement("div").addEventListener("test",function(){},{get capture(){return l=!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"]); | ||
/*! typed-dom v0.0.57 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,u){if(!r[c]){if(!t[c]){var a="function"==typeof require&&require;if(!u&&a)return a(c,!0);if(o)return o(c,!0);var l=new Error("Cannot find module '"+c+"'");throw l.code="MODULE_NOT_FOUND",l}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";function n(e){var t=e.element;if(null!==t.parentElement&&a.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 u;!function(e){e.Void="void",e.Text="text",e.Collection="collection",e.Struct="struct"}(u||(u={}));var a=new WeakSet,l=function(){function e(e,t){function r(){for(;e.childNodes.length>0;)e.removeChild(e.firstChild)}function o(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_?u.Void:"string"==typeof this.children_?u.Text:Array.isArray(this.children_)?u.Collection:u.Struct,this.tag,n(this),a.add(e),this.type){case u.Void:return;case u.Text:return r(),this.children_=document.createTextNode(""),this.element_.appendChild(this.children_),void(this.children=t);case u.Collection:return r(),this.children_=[],this.children=t,void o(this.element_.id,this.children_);case u.Struct:return r(),this.children_=function(e,t){return Object.defineProperties(t,Object.keys(t).reduce(function(r,i){var o=t[i];return n(o),e.appendChild(o.element),r[i]={configurable:!0,enumerable:!0,get:function(){return o},set:function(t){var r=o;t!==r&&(n(t),o=t,e.replaceChild(t.element,r.element))}},r},{}))}(this.element_,i({},t)),void o(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 u.Text:return this.children_.data;default:return this.children_}},set:function(e){var t=this;switch(this.type){case u.Void:return;case u.Text:return void(this.children_.data=e);case u.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){n(e),t.children_[r]=e,t.element_.appendChild(e.element)}),void Object.freeze(this.children_);case u.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}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","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,o,c){switch(void 0===c&&(c=t),c="any"===t?c:t,typeof e){case"undefined":return new i.El(n(c,function(){return document.createElement(c)}),void 0);case"function":return new i.El(n(c,e),void 0);case"string":return new i.El(n(c,r||function(){return document.createElement(c)}),e);case"object":return o="function"==typeof r?r:o||function(){return document.createElement(c)},Object.keys(e).slice(-1).every(function(t){return void 0===t||"object"==typeof e[t]})?new i.El(n(c,o),e):new i.El(n(c,o,e),r===o?void 0:r);default:throw new TypeError("TypedDOM: Invalid arguments: ["+e+", "+r+", "+o+"]")}},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,n,i){function c(e){"object"==typeof i&&i.passive&&(e.preventDefault=l.noop),r.currentTargets.set(e,e.currentTarget),n(e)}void 0===i&&(i=!1),e.addEventListener(t,c,o(i));var u=function(){return u=l.noop,void e.removeEventListener(t,c,o(i))};return function(){return void u()}}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 d?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},u=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},a=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e};Object.defineProperty(r,"__esModule",{value:!0});var l=e("./noop");r.currentTargets=new WeakMap,r.bind=n,r.once=i,r.delegate=function(e,t,r,o,u){return void 0===u&&(u={}),n(e instanceof Document?e.documentElement:e,r,function(n){var c=n.target.closest(t);c&&a(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 d=!1;try{document.createElement("div").addEventListener("test",function(){},{get capture(){return d=!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.56", | ||
"version": "0.0.57", | ||
"description": "Static typed dom component builder.", | ||
@@ -60,3 +60,3 @@ "private": false, | ||
"run-sequence": "^2.2.0", | ||
"spica": "0.0.111", | ||
"spica": "0.0.112", | ||
"tsify": "^3.0.3", | ||
@@ -63,0 +63,0 @@ "typescript": "2.6.0-dev.20171007", |
@@ -38,3 +38,3 @@ type ElChildrenType = | ||
this.tag; | ||
if (memory.has(element_.parentElement!)) throw new Error(`TypedDOM: Cannot use a child element of another typed dom.`); | ||
void throwErrorIfNotUsable(this); | ||
void memory.add(element_); | ||
@@ -91,3 +91,3 @@ switch (this.type) { | ||
let current = children[key]; | ||
if (!isOrphan(current)) throw new Error(`TypedDOM: Cannot add a child element used in another typed dom.`); | ||
void throwErrorIfNotUsable(current); | ||
void element.appendChild(current.element); | ||
@@ -103,3 +103,3 @@ descs[key] = { | ||
if (newChild === oldChild) return; | ||
if (!isOrphan(newChild)) throw new Error(`TypedDOM: Cannot add a child element used in another typed dom.`); | ||
void throwErrorIfNotUsable(newChild); | ||
current = newChild; | ||
@@ -155,3 +155,3 @@ void element.replaceChild(newChild.element, oldChild.element); | ||
.forEach((child, i) => { | ||
if (!isOrphan(child)) throw new Error(`TypedDOM: Cannot add a child element used in another typed dom.`); | ||
void throwErrorIfNotUsable(child); | ||
this.children_![i] = child; | ||
@@ -178,6 +178,5 @@ void this.element_.appendChild(child.element); | ||
function isOrphan({ element }: El<string, HTMLElement, any>): boolean { | ||
return element.parentNode === null | ||
|| element.parentNode instanceof DocumentFragment | ||
|| !memory.has(element.parentElement!); | ||
function throwErrorIfNotUsable({ element }: El<string, HTMLElement, any>): void { | ||
if (element.parentElement === null || !memory.has(element.parentElement)) return; | ||
throw new Error(`TypedDOM: Cannot add an element used in another typed dom.`); | ||
} |
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
104883
1738