dom-augmentor
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -15,10 +15,7 @@ 'use strict'; | ||
const find = node => { | ||
const {childNodes} = node; | ||
const {length} = childNodes; | ||
let i = 0; | ||
while (i < length) { | ||
const child = childNodes[i++]; | ||
if (child.nodeType === 1) | ||
return child; | ||
} | ||
let {firstChild} = node; | ||
while (firstChild && firstChild.nodeType !== 1) | ||
firstChild = firstChild.nextSibling; | ||
if (firstChild) | ||
return firstChild; | ||
throw 'unobservable'; | ||
@@ -25,0 +22,0 @@ }; |
@@ -13,10 +13,7 @@ /*! (c) Andrea Giammarchi - ISC */ | ||
const find = node => { | ||
const {childNodes} = node; | ||
const {length} = childNodes; | ||
let i = 0; | ||
while (i < length) { | ||
const child = childNodes[i++]; | ||
if (child.nodeType === 1) | ||
return child; | ||
} | ||
let {firstChild} = node; | ||
while (firstChild && firstChild.nodeType !== 1) | ||
firstChild = firstChild.nextSibling; | ||
if (firstChild) | ||
return firstChild; | ||
throw 'unobservable'; | ||
@@ -23,0 +20,0 @@ }; |
10
index.js
@@ -452,11 +452,9 @@ var augmentor = (function (exports) { | ||
var find = function find(node) { | ||
var childNodes = node.childNodes; | ||
var length = childNodes.length; | ||
var i = 0; | ||
var firstChild = node.firstChild; | ||
while (i < length) { | ||
var child = childNodes[i++]; | ||
if (child.nodeType === 1) return child; | ||
while (firstChild && firstChild.nodeType !== 1) { | ||
firstChild = firstChild.nextSibling; | ||
} | ||
if (firstChild) return firstChild; | ||
throw 'unobservable'; | ||
@@ -463,0 +461,0 @@ }; |
/*! (c) Andrea Giammarchi - ISC */ | ||
var augmentor=function(n){"use strict";var e={};e.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(n){return e.prototype=new e("").constructor.prototype,e;function e(n,e){e||(e={});var t=document.createEvent("CustomEvent");return t.initCustomEvent(n,!!e.bubbles,!!e.cancelable,e.detail),t}}();var t=e.CustomEvent,r={};try{r.WeakSet=WeakSet}catch(n){!function(n){var e=new n,t=u.prototype;function u(t){e.set(this,new n),t&&t.forEach(this.add,this)}t.add=function(n){return e.get(this).set(n,1),this},t.delete=function(n){return e.get(this).delete(n)},t.has=function(n){return e.get(this).has(n)},r.WeakSet=u}(WeakMap)}var u=r.WeakSet;var o="function"==typeof cancelAnimationFrame,a=o?cancelAnimationFrame:clearTimeout,c=o?requestAnimationFrame:setTimeout;function i(n){var e,t,r,u,i;return f(),function(n,o,a){return r=n,u=o,i=a,t||(t=c(s)),--e<0&&l(!0),l};function s(){f(),r.apply(u,i||[])}function f(){e=n||1/0,t=o?0:null}function l(n){var e=!!t;return e&&(a(t),n&&s()),e}}var s=function(n){return{get:function(e){return n.get(e)},set:function(e,t){return n.set(e,t),t}}},f=null,l=function(n){var e=[];return function t(){var r=f,u=[];f={hook:t,args:arguments,stack:e,i:0,length:e.length,after:u};try{return n.apply(null,arguments)}finally{f=r;for(var o=0,a=u.length;o<a;o++)u[o]()}}},v=s(new WeakMap),h=function(n,e,t){n.apply(e,t)},d={async:!1,always:!1},p=function(n,e){var t=f.i++,r=f,u=r.hook,o=r.args,a=r.stack,c=r.length,s=e||d,l=s.async,p=s.always;t===c&&(f.length=a.push({$:"function"==typeof n?n():n,_:l?v.get(u)||v.set(u,i()):h}));var g=a[t];return[g.$,function(n){var e="function"==typeof n?n(g.$):n;(p||g.$!==e)&&(g.$=e,g._(u,null,o))}]},g=new WeakMap,m=function(n){var e=n.hook,t=n.args;e.apply(null,t)};function y(n){this.value!==n&&(this.value=n,g.get(this).forEach(m))}function k(n){return n.hook===this.hook}var E=new WeakMap,w=s(E),b=function(){},W=function(n){return function(e,t){var r=f.i++,u=f,o=u.hook,a=u.after,c=u.stack;if(r<u.length){var s=c[r],l=s.update,v=s.values,h=s.stop;if(!t||t.some(S,v)){s.values=t,n&&h(n);var d=s.clean;d&&(s.clean=null,d());var p=function(){s.clean=e()};n?l(p):a.push(p)}}else{var g=n?i():b,m={clean:null,update:g,values:t,stop:b};f.length=c.push(m),(w.get(o)||w.set(o,[])).push(m);var y=function(){m.clean=e()};n?m.stop=g(y):a.push(y)}}},C=E.has.bind(E),N=W(!0),M=W(!1),$=function(n,e){var t=f.i++,r=f,u=r.stack;return t===r.length?f.length=u.push({$:n(),_:e}):e&&!e.some(S,u[t]._)||(u[t]={$:n(),_:e}),u[t].$};function S(n,e){return n!==this[e]}var T=function(n){var e=n.Event,t=n.WeakSet,r=!0,u=null;return function(n){return r&&(r=!r,u=new t,function(n){var r=new t,o=new t;try{new MutationObserver(s).observe(n,{subtree:!0,childList:!0})}catch(e){var a=0,c=[],i=function(n){c.push(n),clearTimeout(a),a=setTimeout(function(){s(c.splice(a=0,c.length))},0)};n.addEventListener("DOMNodeRemoved",function(n){i({addedNodes:[],removedNodes:[n.target]})},!0),n.addEventListener("DOMNodeInserted",function(n){i({addedNodes:[n.target],removedNodes:[]})},!0)}function s(n){for(var e,t=n.length,u=0;u<t;u++)f((e=n[u]).removedNodes,"disconnected",o,r),f(e.addedNodes,"connected",r,o)}function f(n,t,r,u){for(var o,a=new e(t),c=n.length,i=0;i<c;1===(o=n[i++]).nodeType&&l(o,a,t,r,u));}function l(n,e,t,r,o){u.has(n)&&!r.has(n)&&(o.delete(n),r.add(n),n.dispatchEvent(e));for(var a=n.children||[],c=a.length,i=0;i<c;l(a[i++],e,t,r,o));}}(n.ownerDocument)),u.add(n),n}}({Event:t,WeakSet:u});return n.augmentor=function(n){var e=null,t=l(n);return function(){var n=t.apply(this,arguments);return C(t)&&function n(e,t){var r=e.nodeType;if(r){var u=1===r?e:function(n){for(var e=n.childNodes,t=e.length,r=0;r<t;){var u=e[r++];if(1===u.nodeType)return u}throw"unobservable"}(e);T(u),u.addEventListener("disconnected",t,!1)}else{var o=e.valueOf();o!==e&&n(o,t)}}(n,e||(e=function(n){(E.get(n)||[]).forEach(function(n){var e=n.clean;(0,n.stop)(),e&&(n.clean=null,e())})}.bind(null,t))),n}},n.contextual=function(n){var e=!0,t=null,r=l(function(){return n.apply(t,arguments)});return function n(){var u=r.apply(t=this,arguments);return e&&(e=!e,C(r)&&E.set(n,E.get(r))),u}},n.createContext=function(n){var e={value:n,provide:y};return g.set(e,[]),e},n.useCallback=function(n,e){return $(function(){return n},e)},n.useContext=function(n){var e=f,t=e.hook,r=e.args,u=g.get(n),o={hook:t,args:r};return u.some(k,o)||u.push(o),n.value},n.useEffect=N,n.useLayoutEffect=M,n.useMemo=$,n.useReducer=function(n,e,t,r){var u="function"==typeof t,o=p(u?t(e):e,u?r:t);return[o[0],function(e){o[1](n(o[0],e))}]},n.useRef=function(n){var e=f.i++,t=f,r=t.stack;return e===t.length&&(f.length=r.push({current:n})),r[e]},n.useState=p,n}({}); | ||
var augmentor=function(n){"use strict";var t={};t.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(n){return t.prototype=new t("").constructor.prototype,t;function t(n,t){t||(t={});var e=document.createEvent("CustomEvent");return e.initCustomEvent(n,!!t.bubbles,!!t.cancelable,t.detail),e}}();var e=t.CustomEvent,r={};try{r.WeakSet=WeakSet}catch(n){!function(n){var t=new n,e=u.prototype;function u(e){t.set(this,new n),e&&e.forEach(this.add,this)}e.add=function(n){return t.get(this).set(n,1),this},e.delete=function(n){return t.get(this).delete(n)},e.has=function(n){return t.get(this).has(n)},r.WeakSet=u}(WeakMap)}var u=r.WeakSet;var o="function"==typeof cancelAnimationFrame,a=o?cancelAnimationFrame:clearTimeout,i=o?requestAnimationFrame:setTimeout;function c(n){var t,e,r,u,c;return f(),function(n,o,a){return r=n,u=o,c=a,e||(e=i(s)),--t<0&&l(!0),l};function s(){f(),r.apply(u,c||[])}function f(){t=n||1/0,e=o?0:null}function l(n){var t=!!e;return t&&(a(e),n&&s()),t}}var s=function(n){return{get:function(t){return n.get(t)},set:function(t,e){return n.set(t,e),e}}},f=null,l=function(n){var t=[];return function e(){var r=f,u=[];f={hook:e,args:arguments,stack:t,i:0,length:t.length,after:u};try{return n.apply(null,arguments)}finally{f=r;for(var o=0,a=u.length;o<a;o++)u[o]()}}},v=s(new WeakMap),h=function(n,t,e){n.apply(t,e)},d={async:!1,always:!1},p=function(n,t){var e=f.i++,r=f,u=r.hook,o=r.args,a=r.stack,i=r.length,s=t||d,l=s.async,p=s.always;e===i&&(f.length=a.push({$:"function"==typeof n?n():n,_:l?v.get(u)||v.set(u,c()):h}));var g=a[e];return[g.$,function(n){var t="function"==typeof n?n(g.$):n;(p||g.$!==t)&&(g.$=t,g._(u,null,o))}]},g=new WeakMap,m=function(n){var t=n.hook,e=n.args;t.apply(null,e)};function y(n){this.value!==n&&(this.value=n,g.get(this).forEach(m))}function k(n){return n.hook===this.hook}var E=new WeakMap,w=s(E),b=function(){},C=function(n){return function(t,e){var r=f.i++,u=f,o=u.hook,a=u.after,i=u.stack;if(r<u.length){var s=i[r],l=s.update,v=s.values,h=s.stop;if(!e||e.some($,v)){s.values=e,n&&h(n);var d=s.clean;d&&(s.clean=null,d());var p=function(){s.clean=t()};n?l(p):a.push(p)}}else{var g=n?c():b,m={clean:null,update:g,values:e,stop:b};f.length=i.push(m),(w.get(o)||w.set(o,[])).push(m);var y=function(){m.clean=t()};n?m.stop=g(y):a.push(y)}}},W=E.has.bind(E),M=C(!0),N=C(!1),S=function(n,t){var e=f.i++,r=f,u=r.stack;return e===r.length?f.length=u.push({$:n(),_:t}):t&&!t.some($,u[e]._)||(u[e]={$:n(),_:t}),u[e].$};function $(n,t){return n!==this[t]}var T=function(n){var t=n.Event,e=n.WeakSet,r=!0,u=null;return function(n){return r&&(r=!r,u=new e,function(n){var r=new e,o=new e;try{new MutationObserver(s).observe(n,{subtree:!0,childList:!0})}catch(t){var a=0,i=[],c=function(n){i.push(n),clearTimeout(a),a=setTimeout(function(){s(i.splice(a=0,i.length))},0)};n.addEventListener("DOMNodeRemoved",function(n){c({addedNodes:[],removedNodes:[n.target]})},!0),n.addEventListener("DOMNodeInserted",function(n){c({addedNodes:[n.target],removedNodes:[]})},!0)}function s(n){for(var t,e=n.length,u=0;u<e;u++)f((t=n[u]).removedNodes,"disconnected",o,r),f(t.addedNodes,"connected",r,o)}function f(n,e,r,u){for(var o,a=new t(e),i=n.length,c=0;c<i;1===(o=n[c++]).nodeType&&l(o,a,e,r,u));}function l(n,t,e,r,o){u.has(n)&&!r.has(n)&&(o.delete(n),r.add(n),n.dispatchEvent(t));for(var a=n.children||[],i=a.length,c=0;c<i;l(a[c++],t,e,r,o));}}(n.ownerDocument)),u.add(n),n}}({Event:e,WeakSet:u});return n.augmentor=function(n){var t=null,e=l(n);return function(){var n=e.apply(this,arguments);return W(e)&&function n(t,e){var r=t.nodeType;if(r){var u=1===r?t:function(n){for(var t=n.firstChild;t&&1!==t.nodeType;)t=t.nextSibling;if(t)return t;throw"unobservable"}(t);T(u),u.addEventListener("disconnected",e,!1)}else{var o=t.valueOf();o!==t&&n(o,e)}}(n,t||(t=function(n){(E.get(n)||[]).forEach(function(n){var t=n.clean;(0,n.stop)(),t&&(n.clean=null,t())})}.bind(null,e))),n}},n.contextual=function(n){var t=!0,e=null,r=l(function(){return n.apply(e,arguments)});return function n(){var u=r.apply(e=this,arguments);return t&&(t=!t,W(r)&&E.set(n,E.get(r))),u}},n.createContext=function(n){var t={value:n,provide:y};return g.set(t,[]),t},n.useCallback=function(n,t){return S(function(){return n},t)},n.useContext=function(n){var t=f,e=t.hook,r=t.args,u=g.get(n),o={hook:e,args:r};return u.some(k,o)||u.push(o),n.value},n.useEffect=M,n.useLayoutEffect=N,n.useMemo=S,n.useReducer=function(n,t,e,r){var u="function"==typeof e,o=p(u?e(t):t,u?r:e);return[o[0],function(t){o[1](n(o[0],t))}]},n.useRef=function(n){var t=f.i++,e=f,r=e.stack;return t===e.length&&(f.length=r.push({current:n})),r[t]},n.useState=p,n}({}); |
{ | ||
"name": "dom-augmentor", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "DOM oriented useEffect hooks for the augmentor", | ||
@@ -5,0 +5,0 @@ "main": "cjs/index.js", |
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
27413
587