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.23 to 0.0.24

24

dist/typed-dom.js

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

/*! typed-dom v0.0.23 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */
/*! typed-dom v0.0.24 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */
require = function e(t, n, r) {

@@ -60,2 +60,4 @@ function s(o, u) {

switch (this.mode) {
case 'empty':
return;
case 'text':

@@ -65,7 +67,7 @@ this.children_ = document.createTextNode('');

this.children = children_;
break;
return;
case 'collection':
this.children_ = Object.freeze([]);
this.children = children_;
break;
return;
case 'struct':

@@ -76,3 +78,3 @@ this.children_ = this.observe(__assign({}, children_));

});
break;
return;
}

@@ -99,10 +101,12 @@ }

switch (this.mode) {
case 'empty':
return;
case 'text':
if (children === this.children_.data)
break;
return;
this.children_.data = children;
break;
return;
case 'collection':
if (children === this.children_)
break;
return;
if (!Object.isFrozen(this.children_))

@@ -124,10 +128,10 @@ throw new Error('TypedHTMLElement collections cannot be updated recursively.');

void Object.freeze(this.children_);
break;
return;
case 'struct':
if (children === this.children_)
break;
return;
void this.structkeys.forEach(function (k) {
return _this.children_[k] = children[k];
});
break;
return;
}

@@ -134,0 +138,0 @@ },

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

/*! typed-dom v0.0.23 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */
require=function e(t,r,n){function i(c,s){if(!r[c]){if(!t[c]){var d="function"==typeof require&&require;if(!s&&d)return d(c,!0);if(o)return o(c,!0);var u=new Error("Cannot find module '"+c+"'");throw u.code="MODULE_NOT_FOUND",u}var a=r[c]={exports:{}};t[c][0].call(a.exports,function(e){var r=t[c][1][e];return i(r?r:e)},a,a.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},i=function(){function e(e,t){var r=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"text":this.children_=document.createTextNode(""),void this.element_.appendChild(this.children_),this.children=t;break;case"collection":this.children_=Object.freeze([]),this.children=t;break;case"struct":this.children_=this.observe(n({},t)),void this.structkeys.forEach(function(e){return void r.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"text":if(e===this.children_.data)break;this.children_.data=e;break;case"collection":if(e===this.children_)break;if(!Object.isFrozen(this.children_))throw new Error("TypedHTMLElement collections cannot be updated recursively.");void e.reduce(function(e,t){var r=e.indexOf(t);return r===-1?e:(void e.splice(r,1),e)},this.children_.slice()).forEach(function(e){return void e.element.remove()}),this.children_=[],void e.forEach(function(e,r){return t.children_[r]=e,void t.element_.appendChild(e.element)}),void Object.freeze(this.children_);break;case"struct":if(e===this.children_)break;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,void t.element_.replaceChild(e.element,r.element))}},r},{}))},e}();r.TypedHTMLElement=i},{}],4:[function(e,t,r){"use strict";function n(e,t){return void Object.keys(e).forEach(function(r){return void t.setAttribute(r,e[r]||"")}),t}var i=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","meter","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 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";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 i=e("./src/export");r.default=i.default,r.__esModule=!0},{"./src/export":5}]},{},[1,2,6,"typed-dom"]);
/*! typed-dom v0.0.24 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | MIT License */
require=function e(t,r,n){function i(c,s){if(!r[c]){if(!t[c]){var u="function"==typeof require&&require;if(!s&&u)return u(c,!0);if(o)return o(c,!0);var d=new Error("Cannot find module '"+c+"'");throw d.code="MODULE_NOT_FOUND",d}var a=r[c]={exports:{}};t[c][0].call(a.exports,function(e){var r=t[c][1][e];return i(r?r:e)},a,a.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},i=function(){function e(e,t){var r=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(""),void this.element_.appendChild(this.children_),void(this.children=t);case"collection":return this.children_=Object.freeze([]),void(this.children=t);case"struct":return this.children_=this.observe(n({},t)),void void this.structkeys.forEach(function(e){return void r.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 void e.reduce(function(e,t){var r=e.indexOf(t);return r===-1?e:(void e.splice(r,1),e)},this.children_.slice()).forEach(function(e){return void e.element.remove()}),this.children_=[],void e.forEach(function(e,r){return t.children_[r]=e,void t.element_.appendChild(e.element)}),void void Object.freeze(this.children_);case"struct":if(e===this.children_)return;return void 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,void t.element_.replaceChild(e.element,r.element))}},r},{}))},e}();r.TypedHTMLElement=i},{}],4:[function(e,t,r){"use strict";function n(e,t){return void Object.keys(e).forEach(function(r){return void t.setAttribute(r,e[r]||"")}),t}var i=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","meter","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 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";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 i=e("./src/export");r.default=i.default,r.__esModule=!0},{"./src/export":5}]},{},[1,2,6,"typed-dom"]);
{
"name": "typed-dom",
"version": "0.0.23",
"version": "0.0.24",
"description": "Static typed dom component builder.",

@@ -58,5 +58,5 @@ "private": false,

"run-sequence": "^1.2.2",
"spica": "0.0.46",
"tsify": "^3.0.0",
"typescript": "2.2.0-dev.20170115",
"spica": "0.0.47",
"tsify": "^3.0.1",
"typescript": "2.2.0-dev.20170128",
"vinyl-buffer": "^1.0.0",

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

@@ -45,8 +45,7 @@ # typed-dom

E extends HTMLElement,
C extends TypedHTMLElementChildren,
> extends AbstractTypedHTMLElement<T> {
C extends TypedHTMLElementChildren
>
extends AbstractTypedHTMLElement<T> {
readonly element: E;
children: C;
buffer(): Promise<undefined>;
render(): void;
}

@@ -62,4 +61,4 @@ type TypedHTMLElementChildren

}
abstract class AbstractTypedHTMLElement<E extends string> {
private identifier: E;
abstract class AbstractTypedHTMLElement<T extends string> {
private identifier: T;
}

@@ -66,0 +65,0 @@ ```

@@ -15,4 +15,5 @@ import { TypedHTMLElement as ITypedHTMLElement } from 'typed-dom';

E extends HTMLElement,
C extends TypedHTMLElementChildren,
> extends ITypedHTMLElement<T, E, C> {
C extends TypedHTMLElementChildren
>
extends ITypedHTMLElement<T, E, C> {
}

@@ -22,4 +23,4 @@ export class TypedHTMLElement<

E extends HTMLElement,
C extends TypedHTMLElementChildren,
>
C extends TypedHTMLElementChildren
>
implements ITypedHTMLElement<T, E, C> {

@@ -32,2 +33,4 @@ constructor(

switch (this.mode) {
case 'empty':
return;
case 'text':

@@ -37,7 +40,7 @@ this.children_ = <any>document.createTextNode('');

this.children = children_;
break;
return;
case 'collection':
this.children_ = <C><TypedHTMLElementChildren.Collection><never[]>Object.freeze([]);
this.children = children_;
break;
return;
case 'struct':

@@ -48,3 +51,3 @@ this.children_ = <C>this.observe({ ...<TypedHTMLElementChildren.Struct>children_ });

void this.element_.appendChild(children_[k].element));
break;
return;
}

@@ -75,9 +78,12 @@ }

switch (this.mode) {
case 'empty':
return;
case 'text':
if (children === (<Text><any>this.children_).data) break;
if (children === (<Text><any>this.children_).data) return;
(<Text><any>this.children_).data = <string>children;
break;
return;
case 'collection':
if (children === this.children_) break;
if (children === this.children_) return;
if (!Object.isFrozen(this.children_)) throw new Error('TypedHTMLElement collections cannot be updated recursively.');

@@ -99,10 +105,10 @@ void (<TypedHTMLElementChildren.Collection>children)

void Object.freeze(this.children_);
break;
return;
case 'struct':
if (children === this.children_) break;
if (children === this.children_) return;
void this.structkeys
.forEach(k =>
this.children_[k] = children[k]);
break;
return;

@@ -112,21 +118,23 @@ }

private observe<C extends TypedHTMLElementChildren.Struct>(children: C): C {
return Object.defineProperties(children, this.structkeys
.reduce<PropertyDescriptorMap>((descs, key) => {
let current = children[key];
descs[key] = {
configurable: true,
enumerable: true,
get: (): ITypedHTMLElement<string, HTMLElement, any> => {
return current;
},
set: (newChild: TypedHTMLElement<string, HTMLElement, any>) => {
const oldChild = current;
if (newChild === oldChild) return;
current = newChild;
void this.element_.replaceChild(newChild.element, oldChild.element);
}
};
return descs;
}, {}));
return Object.defineProperties(
children,
this.structkeys
.reduce<PropertyDescriptorMap>((descs, key) => {
let current = children[key];
descs[key] = {
configurable: true,
enumerable: true,
get: (): ITypedHTMLElement<string, HTMLElement, any> => {
return current;
},
set: (newChild: TypedHTMLElement<string, HTMLElement, any>) => {
const oldChild = current;
if (newChild === oldChild) return;
current = newChild;
void this.element_.replaceChild(newChild.element, oldChild.element);
}
};
return descs;
}, {}));
}
}

@@ -14,4 +14,5 @@ /**

E extends HTMLElement,
C extends TypedHTMLElementChildren,
> extends AbstractTypedHTMLElement<T> {
C extends TypedHTMLElementChildren
>
extends AbstractTypedHTMLElement<T> {
readonly element: E;

@@ -29,4 +30,4 @@ children: C;

}
abstract class AbstractTypedHTMLElement<E extends string> {
private identifier: E;
abstract class AbstractTypedHTMLElement<T extends string> {
private identifier: T;
}

@@ -33,0 +34,0 @@

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