Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typed-dom

Package Overview
Dependencies
Maintainers
1
Versions
350
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-dom - npm Package Compare versions

Comparing version 0.0.54 to 0.0.55

6

dist/typed-dom.js

@@ -1,2 +0,2 @@

/*! typed-dom v0.0.54 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */
/*! typed-dom v0.0.55 https://github.com/falsandtru/typed-dom | (c) 2017, falsandtru | (Apache-2.0 AND MPL-2.0) License */
require = function e(t, n, r) {

@@ -78,2 +78,3 @@ function s(o, u) {

}(ElChildrenType || (ElChildrenType = {})));
var memory = new WeakSet();
var El = function () {

@@ -85,2 +86,3 @@ function El(element_, children_) {

this.tag;
void memory.add(element_);
switch (this.type) {

@@ -211,3 +213,3 @@ case ElChildrenType.Void:

var element = _a.element;
return element.parentNode === null || element.parentNode instanceof DocumentFragment;
return element.parentNode === null || element.parentNode instanceof DocumentFragment || !memory.has(element);
}

@@ -214,0 +216,0 @@ },

@@ -1,2 +0,2 @@

/*! typed-dom v0.0.54 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}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=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)})}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,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 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 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 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=a},{}],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.55 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)}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)})}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,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 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 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 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"]);
{
"name": "typed-dom",
"version": "0.0.54",
"version": "0.0.55",
"description": "Static typed dom component builder.",

@@ -55,10 +55,10 @@ "private": false,

"karma-mocha": "^1.3.0",
"mocha": "^3.5.3",
"npm-check-updates": "^2.12.1",
"mocha": "^4.0.1",
"npm-check-updates": "^2.13.0",
"power-assert": "^1.4.4",
"pump": "^1.0.2",
"run-sequence": "^2.2.0",
"spica": "0.0.108",
"spica": "0.0.111",
"tsify": "^3.0.3",
"typescript": "2.6.0-dev.20170930",
"typescript": "2.6.0-dev.20171007",
"vinyl-buffer": "^1.0.0",

@@ -65,0 +65,0 @@ "vinyl-source-stream": "^1.1.0",

@@ -25,2 +25,4 @@ type ElChildrenType =

const memory = new WeakSet<HTMLElement>();
export class El<

@@ -37,2 +39,3 @@ T extends string,

this.tag;
void memory.add(element_);
switch (this.type) {

@@ -174,3 +177,4 @@ case ElChildrenType.Void:

return element.parentNode === null
|| element.parentNode instanceof DocumentFragment;
|| element.parentNode instanceof DocumentFragment
|| !memory.has(element);
}

@@ -17,3 +17,3 @@ import TypedHTML from '../../index';

const dom = TypedHTML.p(() => {
const el = document.createElement('p');
const el = document.createElement('div').appendChild(document.createElement('p'));
el.id = 'test';

@@ -66,5 +66,2 @@ return el;

assert.throws(() => dom.children = TypedHTML.ul([TypedHTML.li(`1`)]).children);
//assert(dom.element.outerHTML === '<ul><li>1</li></ul>');
//assert(dom.children.length === 1);
//assert(dom.children.every(({ element }, i) => element === dom.element.children[i]));
dom.children = [

@@ -71,0 +68,0 @@ TypedHTML.li('2'),

@@ -15,2 +15,3 @@ {

"strictNullChecks": true,
"strictFunctionTypes": false,
"noImplicitAny": true,

@@ -17,0 +18,0 @@ "noImplicitReturns": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc