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

attodom

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attodom - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

13

CHANGELOG.md

@@ -9,13 +9,4 @@ # Change Log

## [0.2.0] - 2017-06-03
### Changed
- c.child now takes multiple children
- c.child now does not automatically clone nodes
## [0.3.0] - 2017-06-04
### Added
- cElement.id(string)
## [0.1.0] - 2017-06-01
- forked from [pico-dom](https://www.npmjs.com/package/pico-dom)

@@ -25,1 +16,3 @@ - no templates

- `.a` short form for attributes
- cElement.id(string)
- setDocument to setWindow

@@ -6,10 +6,12 @@ /* hugov@runbox.com | https://github.com/hville/attodom.git | license:MIT */

exports.D = typeof document !== 'undefined' ? document : null;
exports.W = typeof window !== 'undefined' ? window : null;
/**
* @function setDocument
* @param {Document} doc DOM document
* @return {Document} DOM document
* @function setWindow
* @param {Window} win
* @return {Window}
*/
function setDocument(doc) {
return exports.D = doc
function setWindow(win) {
exports.D = win.document;
return exports.W = win
}

@@ -508,3 +510,3 @@

exports.component = component;
exports.setDocument = setDocument;
exports.setWindow = setWindow;
exports.find = find;

@@ -511,0 +513,0 @@ exports.css = css$$1;

@@ -1,9 +0,9 @@

(function(e){function l(a){this.node=a;a._aD=this}function n(a){this.node=a;a._aD=this}function p(a,b){this.f=Object.create(null);this.i=a;b&&(this.getKey=b);this.node=e.b.createComment("^");this.a=e.b.createComment("$");this.node._aD=this;this.a._aD=this}function q(a,b){this.f=a;b&&(this.select=b);this.node=e.b.createComment("^");this.a=e.b.createComment("$");this.node._aD=this;this.a._aD=this}function t(){for(var a=e.b.styleSheets,b=/^$|^all$/,d=0;d<a.length;++d)if(m=a[d],b.test(m.media.mediaText)&&
!m.disabled)return m;return m=e.b.head.appendChild(e.b.createElement("style")).sheet}e.b="undefined"!==typeof document?document:null;var k=l.prototype={constructor:l,a:null,get parent(){return this.node.parentNode._aD},c:function(a,b){var d=this.constructor.prototype[a],c=d.length,e=b.length===c+1;this[a]=function(){for(var a=arguments.length,f=Array(c),g=0;g<c;++g)f[g]=g<a?arguments[g]:null;if(e){var u=this;b.apply(this,f.concat(function(){if(arguments.length)throw Error("callback takes no argument");
d.apply(u,f)}))}else b.apply(this,f),d.apply(this,f);return this};return this},moveTo:function(a,b){var d=this.node;b=b||null;if(!a)throw Error("invalid parent node");(d.parentNode!==a||b!==d&&b!==d.nextSibling)&&a.insertBefore(d,b);return this},remove:function(){var a=this.node,b=a.parentNode;b&&b.removeChild(a);return this},set:function(a,b){this[a]=b;return this},p:function(a,b){this.node[a]!==b&&(this.node[a]=b);return this},text:function(a){this.node.textContent=a;return this},id:function(a){this.node.setAttribute("id",
a);return this},j:null,handleEvent:function(a){var b=this.j;if(b=b&&b[a.type])b.call(this,a);else throw Error(a.type+" handler mismatch");},update:function(a,b,d){for(var c=this.node.firstChild;c;){var e=c._aD;e?(e.update&&e.update(a,b,d),c=(e.a||c).nextSibling):c=c.nextSibling}return this}};n.prototype={constructor:n,a:null,get parent(){return this.node.parentNode._aD},p:k.p,c:k.c,set:k.set,moveTo:k.moveTo,remove:k.remove,text:k.text,update:k.text};var r=p.prototype={constructor:p,set:k.set,c:k.c,
get parent(){return this.node.parentNode._aD},remove:function(){var a=this.node,b=a.parentNode,d=a.nextSibling;if(b){for(;d!==this.a;){var c=d._aD,d=(c.a||c.node).nextSibling;c.remove()}b.removeChild(this.a);b.removeChild(a)}return this},a:null,moveTo:function(a,b){var d=this.a,c=this.node,e=c.parentNode;b=b||null;if(!a.nodeType)throw Error("invalid parent node");if(e!==a||b!==d&&b!==d.nextSibling)if(e){do c=(e=c).nextSibling;while(a.insertBefore(e,b)!==d)}else a.insertBefore(c,b),a.insertBefore(d,
b);return this},g:function(a,b,d,c){d?b.node===d.nextSibling?d._aD.moveTo(a,c):b.node!==d&&b.moveTo(a,d):b.moveTo(a);return b.a||b.node},getKey:function(a,b){return b},update:function(a){var b=this.a,d=b.parentNode,c=this.node.nextSibling,e=this.f,k=Object.create(null);if(!d)throw Error("list update requires a parent node");for(var f=0;f<a.length;++f){var g=this.getKey(a[f],f,a);g=k[g]=e[g]||this.i(g,a[f],f,a);c=this.g(d,g,c,b).nextSibling;g.update&&g.update(a[f],f,a)}for(this.f=k;c!==this.a;)g=c._aD,
c=(g.a||g.node).nextSibling,g.remove();return this}};q.prototype={constructor:q,select:function(){return Object.keys(this.f)},set:k.set,c:k.c,get parent(){return this.node.parentNode._aD},a:null,remove:r.remove,moveTo:r.moveTo,g:r.g,update:function(a,b,d){var c,e=this.a,k=e.parentNode,f=this.node.nextSibling,g=this.f,m=this.select(a,b,d);if(!k)throw Error("select update requires a parent node");for(var l=0;l<m.length;++l)if(c=g[m[l]])f=this.g(k,c,f,e).nextSibling,c.update&&c.update(a,b,d);for(;f!==
this.a;)c=f._aD,f=(c.a||c.node).nextSibling,c.remove();return this}};var m=null;e.text=function(a){return new n(e.b.createTextNode(a))};e.element=function(a){return new l(e.b.createElement(a))};e.u=function(a){return new l(e.b.createElementNS("http://www.w3.org/2000/svg",a))};e.o=function(a,b){return new l(e.b.createElementNS(a,b))};e.list=function(a,b){return new p(a,b)};e.select=function(a,b){return new q(a,b)};e.l=function(a){a._aD&&(a._aD.node=null);return 1===a.nodeType?new l(a):new n(a)};e.s=
function(a){return e.b=a};e.find=function(a,b,d){a=a.node||a;d=d?d.node||d.a||d:null;for(var c=a._aD;!c||b&&!b(c);){if(a===d)return null;c=a.firstChild;if(!c)for(;!(c=a.nextSibling);)if(a=a.parentNode,null===a)return null;a=c;c=a._aD}return c};e.m=function(a){(m||t()).insertRule(a,m.cssRules.length)}})(this.h=this.h||{});
(function(c){function k(a){this.node=a;a._aD=this}function m(a){this.node=a;a._aD=this}function n(a,b){this.f=Object.create(null);this.j=a;b&&(this.getKey=b);this.node=c.b.createComment("^");this.a=c.b.createComment("$");this.node._aD=this;this.a._aD=this}function p(a,b){this.f=a;b&&(this.select=b);this.node=c.b.createComment("^");this.a=c.b.createComment("$");this.node._aD=this;this.a._aD=this}function r(){for(var a=c.b.styleSheets,b=/^$|^all$/,e=0;e<a.length;++e)if(l=a[e],b.test(l.media.mediaText)&&
!l.disabled)return l;return l=c.b.head.appendChild(c.b.createElement("style")).sheet}c.b="undefined"!==typeof document?document:null;c.h="undefined"!==typeof window?window:null;var h=k.prototype={constructor:k,a:null,get parent(){return this.node.parentNode._aD},c:function(a,b){var e=this.constructor.prototype[a],d=e.length,c=b.length===d+1;this[a]=function(){for(var a=arguments.length,f=Array(d),g=0;g<d;++g)f[g]=g<a?arguments[g]:null;if(c){var t=this;b.apply(this,f.concat(function(){if(arguments.length)throw Error("callback takes no argument");
e.apply(t,f)}))}else b.apply(this,f),e.apply(this,f);return this};return this},moveTo:function(a,b){var e=this.node;b=b||null;if(!a)throw Error("invalid parent node");(e.parentNode!==a||b!==e&&b!==e.nextSibling)&&a.insertBefore(e,b);return this},remove:function(){var a=this.node,b=a.parentNode;b&&b.removeChild(a);return this},set:function(a,b){this[a]=b;return this},p:function(a,b){this.node[a]!==b&&(this.node[a]=b);return this},text:function(a){this.node.textContent=a;return this},id:function(a){this.node.setAttribute("id",
a);return this},l:null,handleEvent:function(a){var b=this.l;if(b=b&&b[a.type])b.call(this,a);else throw Error(a.type+" handler mismatch");},update:function(a,b,e){for(var d=this.node.firstChild;d;){var c=d._aD;c?(c.update&&c.update(a,b,e),d=(c.a||d).nextSibling):d=d.nextSibling}return this}};m.prototype={constructor:m,a:null,get parent(){return this.node.parentNode._aD},p:h.p,c:h.c,set:h.set,moveTo:h.moveTo,remove:h.remove,text:h.text,update:h.text};var q=n.prototype={constructor:n,set:h.set,c:h.c,
get parent(){return this.node.parentNode._aD},remove:function(){var a=this.node,b=a.parentNode,e=a.nextSibling;if(b){for(;e!==this.a;){var d=e._aD,e=(d.a||d.node).nextSibling;d.remove()}b.removeChild(this.a);b.removeChild(a)}return this},a:null,moveTo:function(a,b){var e=this.a,d=this.node,c=d.parentNode;b=b||null;if(!a.nodeType)throw Error("invalid parent node");if(c!==a||b!==e&&b!==e.nextSibling)if(c){do d=(c=d).nextSibling;while(a.insertBefore(c,b)!==e)}else a.insertBefore(d,b),a.insertBefore(e,
b);return this},g:function(a,b,e,d){e?b.node===e.nextSibling?e._aD.moveTo(a,d):b.node!==e&&b.moveTo(a,e):b.moveTo(a);return b.a||b.node},getKey:function(a,b){return b},update:function(a){var b=this.a,e=b.parentNode,d=this.node.nextSibling,c=this.f,h=Object.create(null);if(!e)throw Error("list update requires a parent node");for(var f=0;f<a.length;++f){var g=this.getKey(a[f],f,a);g=h[g]=c[g]||this.j(g,a[f],f,a);d=this.g(e,g,d,b).nextSibling;g.update&&g.update(a[f],f,a)}for(this.f=h;d!==this.a;)g=d._aD,
d=(g.a||g.node).nextSibling,g.remove();return this}};p.prototype={constructor:p,select:function(){return Object.keys(this.f)},set:h.set,c:h.c,get parent(){return this.node.parentNode._aD},a:null,remove:q.remove,moveTo:q.moveTo,g:q.g,update:function(a,b,e){var d,c=this.a,h=c.parentNode,f=this.node.nextSibling,g=this.f,l=this.select(a,b,e);if(!h)throw Error("select update requires a parent node");for(var k=0;k<l.length;++k)if(d=g[l[k]])f=this.g(h,d,f,c).nextSibling,d.update&&d.update(a,b,e);for(;f!==
this.a;)d=f._aD,f=(d.a||d.node).nextSibling,d.remove();return this}};var l=null;c.text=function(a){return new m(c.b.createTextNode(a))};c.element=function(a){return new k(c.b.createElement(a))};c.v=function(a){return new k(c.b.createElementNS("http://www.w3.org/2000/svg",a))};c.s=function(a,b){return new k(c.b.createElementNS(a,b))};c.list=function(a,b){return new n(a,b)};c.select=function(a,b){return new p(a,b)};c.m=function(a){a._aD&&(a._aD.node=null);return 1===a.nodeType?new k(a):new m(a)};c.u=
function(a){c.b=a.document;return c.h=a};c.find=function(a,b,c){a=a.node||a;c=c?c.node||c.a||c:null;for(var d=a._aD;!d||b&&!b(d);){if(a===c)return null;d=a.firstChild;if(!d)for(;!(d=a.nextSibling);)if(a=a.parentNode,null===a)return null;a=d;d=a._aD}return d};c.o=function(a){(l||r()).insertRule(a,l.cssRules.length)}})(this.i=this.i||{});

@@ -7,10 +7,12 @@ /* hugov@runbox.com | https://github.com/hville/attodom.git | license:MIT */

exports.D = typeof document !== 'undefined' ? document : null;
exports.W = typeof window !== 'undefined' ? window : null;
/**
* @function setDocument
* @param {Document} doc DOM document
* @return {Document} DOM document
* @function setWindow
* @param {Window} win
* @return {Window}
*/
function setDocument(doc) {
return exports.D = doc
function setWindow(win) {
exports.D = win.document;
return exports.W = win
}

@@ -509,4 +511,4 @@

exports.component = component;
exports.setDocument = setDocument;
exports.setWindow = setWindow;
exports.find = find;
exports.css = css$$1;

@@ -11,4 +11,4 @@ // @ts-check

// utils
export {setDocument, D} from './src/document'
export {setWindow, D, W} from './src/document'
export {find} from './src/find'
export {css} from './src/css'
{
"name": "attodom",
"version": "0.2.0",
"version": "0.3.0",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "module": "./module.js",

@@ -56,3 +56,3 @@ # attodom

* browser: (`attodom.element`)
* server: See `setDocument` below
* server: See `setWindow` below

@@ -165,5 +165,5 @@ Two examples are available:

* `setDocument(document)` to set the Document interface for testing or server use
* eg. `setDocument((new JSDOM).window.document)`
* `D` reference to the Document interface for testing or server use
* `setWindow(window)` to set the window and document interface for testing or server use
* eg. `setWindow((new JSDOM).window)`
* `W` and `D` reference to the `window` ad `document` interface for testing or server use
* eg. `document.body === D.body`

@@ -170,0 +170,0 @@ * `find(from [, test] [, until])` find a component within nodes or components and matching the test function. It parses nodes up and down following the html markup order.

export var D = typeof document !== 'undefined' ? document : null
export var W = typeof window !== 'undefined' ? window : null
/**
* @function setDocument
* @param {Document} doc DOM document
* @return {Document} DOM document
* @function setWindow
* @param {Window} win
* @return {Window}
*/
export function setDocument(doc) {
return D = doc
export function setWindow(win) {
D = win.document
return W = win
}

@@ -7,4 +7,3 @@ var ct = require('cotest'),

var JSDOM = require('jsdom').JSDOM //eslint-disable-line global-require
var win = (new JSDOM).window
P.setDocument(win.document)
P.setWindow((new JSDOM).window)
}

@@ -11,0 +10,0 @@

@@ -7,4 +7,3 @@ var ct = require('cotest'),

var JSDOM = require('jsdom').JSDOM //eslint-disable-line global-require
var win = (new JSDOM).window
P.setDocument(win.document)
P.setWindow((new JSDOM).window)
}

@@ -54,5 +53,5 @@

ct('===', elm.textContent, '')
elm.dispatchEvent(new P.D.defaultView.Event('click'))
elm.dispatchEvent(new P.W.Event('click'))
ct('===', elm.textContent, 'a')
elm.dispatchEvent(new P.D.defaultView.Event('click'))
elm.dispatchEvent(new P.W.Event('click'))
ct('===', elm.textContent, 'aa')

@@ -59,0 +58,0 @@ })

@@ -7,4 +7,3 @@ var ct = require('cotest'),

var JSDOM = require('jsdom').JSDOM //eslint-disable-line global-require
var win = (new JSDOM).window
P.setDocument(win.document)
P.setWindow((new JSDOM).window)
}

@@ -11,0 +10,0 @@

@@ -7,4 +7,3 @@ var ct = require('cotest'),

var JSDOM = require('jsdom').JSDOM //eslint-disable-line global-require
var win = (new JSDOM).window
P.setDocument(win.document)
P.setWindow((new JSDOM).window)
}

@@ -11,0 +10,0 @@

@@ -7,4 +7,3 @@ var ct = require('cotest'),

var JSDOM = require('jsdom').JSDOM //eslint-disable-line global-require
var win = (new JSDOM).window
P.setDocument(win.document)
P.setWindow((new JSDOM).window)
}

@@ -11,0 +10,0 @@

@@ -7,4 +7,3 @@ var ct = require('cotest'),

var JSDOM = require('jsdom').JSDOM //eslint-disable-line global-require
var win = (new JSDOM).window
P.setDocument(win.document)
P.setWindow((new JSDOM).window)
}

@@ -11,0 +10,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