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

simmerjs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simmerjs - npm Package Compare versions

Comparing version 0.5.4 to 0.5.5

lib/methods/validationHelpers.js

49

dist/simmer.js

@@ -1,24 +0,25 @@

var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.owns=function(e,g){return Object.prototype.hasOwnProperty.call(e,g)};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(e,g,p){e!=Array.prototype&&e!=Object.prototype&&(e[g]=p.value)};
$jscomp.getGlobal=function(e){return"undefined"!=typeof window&&window===e?e:"undefined"!=typeof global&&null!=global?global:e};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(e,g,p,l){if(g){p=$jscomp.global;e=e.split(".");for(l=0;l<e.length-1;l++){var x=e[l];x in p||(p[x]={});p=p[x]}e=e[e.length-1];l=p[e];g=g(l);g!=l&&null!=g&&$jscomp.defineProperty(p,e,{configurable:!0,writable:!0,value:g})}};
$jscomp.polyfill("Object.assign",function(e){return e?e:function(e,p){for(var l=1;l<arguments.length;l++){var g=arguments[l];if(g)for(var y in g)$jscomp.owns(g,y)&&(e[y]=g[y])}return e}},"es6-impl","es3");
(function(){function e(a){return{el:a,getClass:function(){var a=this.el.getAttribute("class");return a?a:""},getClasses:function(){var a=this.el.getAttribute("class");return a&&"string"===typeof a&&(a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,""),""!==a)?a.split(" "):[]},prevAll:function(){return this.dir("previousSibling")},nextAll:function(){return this.dir("nextSibling")},parent:function(){var a=this.el.parentNode;return a&&11!==a.nodeType?e(a):null},dir:function(a){for(var b=[],d=this.el[a];d&&
9!==d.nodeType;)1===d.nodeType&&b.push(e(d)),d=d[a];return b}}}function g(a,b,c){switch(c.length){case 0:return a.call(b);case 1:return a.call(b,c[0]);case 2:return a.call(b,c[0],c[1]);case 3:return a.call(b,c[0],c[1],c[2])}return a.apply(b,c)}function p(a,b){var c;if(c=!(!a||!a.length)){a:if(b!==b)b:{b=l;c=a.length;for(var d=-1;++d<c;)if(b(a[d],d,a)){a=d;break b}a=-1}else{c=-1;for(d=a.length;++c<d;)if(a[c]===b){a=c;break a}a=-1}c=-1<a}return c}function l(a){return a!==a}function x(a,b){return a.has(b)}
function y(a){var b=!1;if(null!=a&&"function"!=typeof a.toString)try{b=!!(a+"")}catch(c){}return b}function r(a){var b=-1,c=a?a.length:0;for(this.clear();++b<c;){var d=a[b];this.set(d[0],d[1])}}function t(a){var b=-1,c=a?a.length:0;for(this.clear();++b<c;){var d=a[b];this.set(d[0],d[1])}}function u(a){var b=-1,c=a?a.length:0;for(this.clear();++b<c;){var d=a[b];this.set(d[0],d[1])}}function A(a){var b=-1,c=a?a.length:0;for(this.__data__=new u;++b<c;)this.add(a[b])}function B(a,b){for(var c=a.length;c--;){var d=
a[c][0];if(d===b||d!==d&&b!==b)return c}return-1}function L(a,b,c,d,f){var m=-1,h=a.length;c||(c=Y);for(f||(f=[]);++m<h;){var n=a[m];if(0<b&&c(n))if(1<b)L(n,b-1,c,d,f);else for(var e=f,k=-1,g=n.length,l=e.length;++k<g;)e[l+k]=n[k];else d||(f[f.length]=n)}return f}function C(a,b){a=a.__data__;var c="undefined"===typeof b?"undefined":v(b);return("string"==c||"number"==c||"symbol"==c||"boolean"==c?"__proto__"!==b:null===b)?a["string"==typeof b?"string":"hash"]:a.map}function M(a,b){a=null==a?void 0:
a[b];b=!N(a)||O&&O in a?!1:(P(a)||y(a)?Z:aa).test(ba(a));return b?a:void 0}function Y(a){var b;(b=ca(a))||(b=F(a)&&D.call(a,"callee")&&(!da.call(a,"callee")||"[object Arguments]"==Q.call(a)));return b||!!(R&&a&&a[R])}function ba(a){if(null!=a){try{return S.call(a)}catch(b){}return a+""}return""}function F(a){var b;if(b=!!a&&"object"==("undefined"===typeof a?"undefined":v(a))){if(b=null!=a)b=a.length,b="number"==typeof b&&-1<b&&0==b%1&&9007199254740991>=b;b=b&&!P(a)}return b}function P(a){a=N(a)?Q.call(a):
"";return"[object Function]"==a||"[object GeneratorFunction]"==a}function N(a){var b="undefined"===typeof a?"undefined":v(a);return!!a&&("object"==b||"function"==b)}function ea(a){var b=a.getMethods();return{finished:function(){return 0===b.length},next:function(a,d,f,m,h,n){return this.finished()?!1:b.shift()(a,d,f,m,h,n)}}}function T(){return U({},fa,0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}function V(){function a(a,b){if(!0===c.errorHandling)throw a;"function"===typeof c.errorHandling&&
c.errorHandling(a,b)}var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:window,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:T(),d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:W(b,c.queryEngine),f=function h(b){if(!b)return a.call(h,Error("Simmer: No element was specified for parsing."),b),!1;for(var f=new ea(w),k=e(b),n=c.depth,g=[],l=0;l<n&&null!==k;l+=1)g[l]=k,k=g[l].parent();k={stack:[],specificity:0};for(n=0;n<g.length;n+=1)k.stack[n]=[];for(;!f.finished()&&!k.verified;)try{k=
f.next(g,k,c,G,d,a),k.specificity>=c.specificityThreshold&&!k.verified&&(k.verified=G(b,k,c.selectorMaxLength,d,a))}catch(ga){a.call(h,ga,b)}if(void 0===k.verified||k.specificity<c.specificityThreshold)k.verified=G(b,k,c.selectorMaxLength,d,a);return k.verified?k.verificationDepth?H(k,k.verificationDepth):H(k):!1};f.configure=function(){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:b,d=T(U({},c,0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}));return V(a,W(a,d.queryEngine),
d)};return f}var ha=function(a){return function(b,c){try{return a.querySelectorAll(b)}catch(d){c(d)}}},W=function(a,b){a=a.document;var c="function"===typeof b?b:ha(a);return function(a,b){return"string"!==typeof a?[]:c(a,b)}},q="undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{},v="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"===typeof Symbol&&a.constructor===Symbol&&a!==
Symbol.prototype?"symbol":typeof a},U=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b],d;for(d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},aa=/^\[object .+?Constructor\]$/,q="object"==v(q)&&q&&q.Object===Object&&q,I="object"==("undefined"===typeof self?"undefined":v(self))&&self&&self.Object===Object&&self,q=q||I||Function("return this")(),I=Array.prototype,E=Function.prototype,J=Object.prototype,K=q["__core-js_shared__"],O=function(){var a=
/[^.]+$/.exec(K&&K.keys&&K.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}(),S=E.toString,D=J.hasOwnProperty,Q=J.toString,Z=RegExp("^"+S.call(D).replace(/[\\^$.*+?()[\]{}|]/g,"\\$\x26").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=q.Symbol,da=J.propertyIsEnumerable,ia=I.splice,R=E?E.isConcatSpreadable:void 0,X=Math.max,ja=M(q,"Map"),z=M(Object,"create");r.prototype.clear=function(){this.__data__=z?z(null):{}};r.prototype["delete"]=function(a){return this.has(a)&&
delete this.__data__[a]};r.prototype.get=function(a){var b=this.__data__;return z?(a=b[a],"__lodash_hash_undefined__"===a?void 0:a):D.call(b,a)?b[a]:void 0};r.prototype.has=function(a){var b=this.__data__;return z?void 0!==b[a]:D.call(b,a)};r.prototype.set=function(a,b){this.__data__[a]=z&&void 0===b?"__lodash_hash_undefined__":b;return this};t.prototype.clear=function(){this.__data__=[]};t.prototype["delete"]=function(a){var b=this.__data__;a=B(b,a);if(0>a)return!1;a==b.length-1?b.pop():ia.call(b,
a,1);return!0};t.prototype.get=function(a){var b=this.__data__;a=B(b,a);return 0>a?void 0:b[a][1]};t.prototype.has=function(a){return-1<B(this.__data__,a)};t.prototype.set=function(a,b){var c=this.__data__,d=B(c,a);0>d?c.push([a,b]):c[d][1]=b;return this};u.prototype.clear=function(){this.__data__={hash:new r,map:new (ja||t),string:new r}};u.prototype["delete"]=function(a){return C(this,a)["delete"](a)};u.prototype.get=function(a){return C(this,a).get(a)};u.prototype.has=function(a){return C(this,
a).has(a)};u.prototype.set=function(a,b){C(this,a).set(a,b);return this};A.prototype.add=A.prototype.push=function(a){this.__data__.set(a,"__lodash_hash_undefined__");return this};A.prototype.has=function(a){return this.__data__.has(a)};var ka=function(a,b){b=X(void 0===b?a.length-1:b,0);return function(){for(var c=arguments,d=-1,f=X(c.length-b,0),m=Array(f);++d<f;)m[d]=c[b+d];d=-1;for(f=Array(b+1);++d<b;)f[d]=c[d];f[b]=m;return g(a,this,f)}}(function(a,b){if(F(a)){b=L(b,1,F,!0);var c=-1,d=p,f=!0,
m=a.length,h=[],e=b.length;if(m)b:for(200<=b.length&&(d=x,f=!1,b=new A(b));++c<m;){var g=a[c],k=g,g=0!==g?g:0;if(f&&k===k){for(var l=e;l--;)if(b[l]===k)continue b;h.push(g)}else d(b,k,void 0)||h.push(g)}a=h}else a=[];return a}),ca=Array.isArray,w={methods:[],getMethods:function(){return this.methods.slice(0)},addMethod:function(a,b){b=b&&"object"===("undefined"===typeof b?"undefined":v(b))?b:this;this.methods.push(a.bind(b))},validationHelpers:{tagName:function(a){return"string"===typeof a&&null!==
a.match(/^[a-zA-Z0-9]+$/gi)?a:!1},attr:function(a){return"string"===typeof a&&null!==a.match(/^[0-9a-zA-Z][a-zA-Z_\-:0-9.]*$/gi)?a:!1},className:function(a){return"string"===typeof a&&null!==a.match(/^\.?[a-zA-Z_\-:0-9]*$/gi)?a:!1}}};w.addMethod(function(a,b,c,d,f,m){var h;for(h=0;h<a.length&&!b.verified;h+=1){var e=a[h];e=this.validationHelpers.attr(e.el.getAttribute("id"));var g;if(g=e)g=1===(f('[id\x3d"'+e+'"]')||[]).length;g&&(b.stack[h].push("[id\x3d'"+e+"']"),b.specificity+=100,0===h?d(a[0],
b,c.selectorMaxLength,f,m)?b.verified=!0:(b.stack[h].pop(),b.specificity-=100):b.specificity>=c.specificityThreshold&&d(a[0],b,c.selectorMaxLength,f,m)&&(b.verified=!0))}return b});w.addMethod(function(a,b){var c;for(c=0;c<a.length;c+=1){var d=a[c];if(d=this.validationHelpers.tagName(d.el.nodeName))b.stack[c].splice(0,0,d),b.specificity+=10}return b});w.addMethod(function(a,b,c,d,f,e){var h=a[0];switch(h.el.nodeName){case "A":if(h=h.el.getAttribute("href"))b.stack[0].push('A[href\x3d"'+h+'"]'),b.specificity+=
10;break;case "IMG":if(h=h.el.getAttribute("src"))b.stack[0].push('IMG[src\x3d"'+h+'"]'),b.specificity+=10;break;default:return b}d(a[0],b,c.selectorMaxLength,f,e)?b.verified=!0:b.stack[0].pop();return b});w.addMethod(function(a,b){var c,d;for(c=0;c<a.length;c+=1){var f=a[c];if((f=f.el.getAttribute("class"))&&"string"===typeof f&&(f=f.replace(/^\s\s*/,"").replace(/\s\s*$/,""),d=f.match(/([^\s]+)/gi))){0<d.length&&(d[0]="."+d[0]);10<d.length&&d.splice(10,d.length-10);for(f=0;f<d.length;f+=1)this.validationHelpers.className(d[f])||
d.splice(f,1);b.stack[c].push(d.join("."));b.specificity+=10*d.length}}return b});w.addMethod(function(a,b,c,d,f,e){for(var h=0,g,m;h<a.length&&!b.verified;)g=a[h].prevAll(),m=g.length+1,g=g.concat(a[h].nextAll()),0!==g.length&&(g=this.analyzeElementSiblings(a[h],g),g||(b.stack[h].push(":nth-child("+m+")"),b.verified=d(a[0],b,c.selectorMaxLength,f,e))),h+=1;return b},{analyzeElementSiblings:function(a,b){var c=a.el.nodeName,d=a.getClasses(),f=!0,e=d[0]instanceof Array&&0<d[0].length,g;for(a=0;a<b.length&&
(e||f);a+=1)e=b[a],(g=e.el.nodeName)&&g===c&&(f=!1),e=0<ka(d,e.getClasses()).length;return e||f}});var H=function(a,b){b=b||a.stack.length;var c=[],d=0,f;for(f=b-1;0<=f;--f)0===a.stack[f].length?f!==b-1-d?c.push("*"):d+=1:c.push(a.stack[f].join(""));return c.join(" \x3e ")},G=function(a,b,c,d,f){for(var e=!1,g=1;g<=b.stack.length&&!e;g+=1){e=H(b,g).trim();if(!e||!e.length||c&&e.length>c)return!1;e=d(e,f);if(e=1===e.length&&(void 0!==a.el?e[0]===a.el:e[0]===a))b.verificationDepth=g}return e},fa={queryEngine:null,
specificityThreshold:100,depth:3,errorHandling:!1,selectorMaxLength:512};(function(a,b){var c=a.Simmer;a.Simmer=b;b.noConflict=function(){a.Simmer=c;return b}})(window,V(window))})();
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.owns=function(f,k){return Object.prototype.hasOwnProperty.call(f,k)};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(f,k,g){f!=Array.prototype&&f!=Object.prototype&&(f[k]=g.value)};
$jscomp.getGlobal=function(f){return"undefined"!=typeof window&&window===f?f:"undefined"!=typeof global&&null!=global?global:f};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(f,k,g,e){if(k){g=$jscomp.global;f=f.split(".");for(e=0;e<f.length-1;e++){var l=f[e];l in g||(g[l]={});g=g[l]}f=f[f.length-1];e=g[f];k=k(e);k!=e&&null!=k&&$jscomp.defineProperty(g,f,{configurable:!0,writable:!0,value:k})}};
$jscomp.polyfill("Object.assign",function(f){return f?f:function(f,g){for(var e=1;e<arguments.length;e++){var l=arguments[e];if(l)for(var k in l)$jscomp.owns(l,k)&&(f[k]=l[k])}return f}},"es6-impl","es3");$jscomp.polyfill("Array.prototype.fill",function(f){return f?f:function(f,g,e){var k=this.length||0;0>g&&(g=Math.max(0,k+g));if(null==e||e>k)e=k;e=Number(e);0>e&&(e=Math.max(0,k+e));for(g=Number(g||0);g<e;g++)this[g]=f;return this}},"es6-impl","es3");
(function(){function f(a){return{el:a,getClass:function(){var a=this.el.getAttribute("class");return a?a:""},getClasses:function(){var a=this.el.getAttribute("class");return a&&"string"===typeof a&&(a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,""),""!==a)?a.split(" "):[]},prevAll:function(){return this.dir("previousSibling")},nextAll:function(){return this.dir("nextSibling")},parent:function(){var a=this.el.parentNode;return a&&11!==a.nodeType?f(a):null},dir:function(a){for(var b=[],d=this.el[a];d&&
9!==d.nodeType;)1===d.nodeType&&b.push(f(d)),d=d[a];return b}}}function k(a){return"string"===typeof a&&null!==a.match(/^\.?[a-zA-Z_\-:0-9]*$/gi)?a:!1}function g(a){var b="undefined"===typeof a?"undefined":n(a);return!!a&&("object"==b||"function"==b)}function e(a){if("number"==typeof a)return a;var b=a;if("symbol"==("undefined"===typeof b?"undefined":n(b))||b&&"object"==("undefined"===typeof b?"undefined":n(b))&&"[object Symbol]"==Z.call(b))return I;g(a)&&(a="function"==typeof a.valueOf?a.valueOf():
a,a=g(a)?a+"":a);if("string"!=typeof a)return 0===a?a:+a;a=a.replace(aa,"");return(b=ba.test(a))||ca.test(a)?da(a.slice(2),b?2:8):ea.test(a)?I:+a}function l(a,b,c){switch(c.length){case 0:return a.call(b);case 1:return a.call(b,c[0]);case 2:return a.call(b,c[0],c[1]);case 3:return a.call(b,c[0],c[1],c[2])}return a.apply(b,c)}function Y(a,b){var c;if(c=!(!a||!a.length)){a:if(b!==b)b:{b=fa;c=a.length;for(var d=-1;++d<c;)if(b(a[d],d,a)){a=d;break b}a=-1}else{c=-1;for(d=a.length;++c<d;)if(a[c]===b){a=
c;break a}a=-1}c=-1<a}return c}function fa(a){return a!==a}function ga(a,b){return a.has(b)}function ha(a){var b=!1;if(null!=a&&"function"!=typeof a.toString)try{b=!!(a+"")}catch(c){}return b}function r(a){var b=-1,c=a?a.length:0;for(this.clear();++b<c;){var d=a[b];this.set(d[0],d[1])}}function t(a){var b=-1,c=a?a.length:0;for(this.clear();++b<c;){var d=a[b];this.set(d[0],d[1])}}function u(a){var b=-1,c=a?a.length:0;for(this.clear();++b<c;){var d=a[b];this.set(d[0],d[1])}}function x(a){var b=-1,c=
a?a.length:0;for(this.__data__=new u;++b<c;)this.add(a[b])}function y(a,b){for(var c=a.length;c--;){var d=a[c][0];if(d===b||d!==d&&b!==b)return c}return-1}function J(a,b,c,d,h){var K=-1,p=a.length;c||(c=ia);for(h||(h=[]);++K<p;){var q=a[K];if(0<b&&c(q))if(1<b)J(q,b-1,c,d,h);else for(var f=h,e=-1,g=q.length,k=f.length;++e<g;)f[k+e]=q[e];else d||(h[h.length]=q)}return h}function z(a,b){a=a.__data__;var c="undefined"===typeof b?"undefined":n(b);return("string"==c||"number"==c||"symbol"==c||"boolean"==
c?"__proto__"!==b:null===b)?a["string"==typeof b?"string":"hash"]:a.map}function L(a,b){a=null==a?void 0:a[b];b=!M(a)||N&&N in a?!1:(O(a)||ha(a)?ka:la).test(ma(a));return b?a:void 0}function ia(a){var b;(b=na(a))||(b=C(a)&&A.call(a,"callee")&&(!oa.call(a,"callee")||"[object Arguments]"==P.call(a)));return b||!!(Q&&a&&a[Q])}function ma(a){if(null!=a){try{return R.call(a)}catch(b){}return a+""}return""}function C(a){var b;if(b=!!a&&"object"==("undefined"===typeof a?"undefined":n(a))){if(b=null!=a)b=
a.length,b="number"==typeof b&&-1<b&&0==b%1&&9007199254740991>=b;b=b&&!O(a)}return b}function O(a){a=M(a)?P.call(a):"";return"[object Function]"==a||"[object GeneratorFunction]"==a}function M(a){var b="undefined"===typeof a?"undefined":n(a);return!!a&&("object"==b||"function"==b)}function pa(a){var b=a.getMethods();return{finished:function(){return 0===b.length},next:function(){return this.finished()?!1:b.shift().apply(void 0,arguments)}}}function qa(a,b){for(var c=[],d=0;d<b&&null!==a;d+=1)c[d]=
a,a=c[d].parent();return c}function S(){return T({},ra,0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}function U(){function a(a,b){if(!0===d.errorHandling)throw a;"function"===typeof d.errorHandling&&d.errorHandling(a,b)}var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:window,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:!1,d=S(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}),h=c||V(b,d.queryEngine),c=function p(b){if(!b)return a.call(p,Error("Simmer: No element was specified for parsing."),
b),!1;for(var c=new pa(v),q=qa(f(b),d.depth),e={stack:Array(q.length).fill().map(function(){return[]}),specificity:0};!c.finished()&&!e.verified;)try{e=c.next(q,e,d,D,h,a),e.specificity>=d.specificityThreshold&&!e.verified&&(e.verified=D(b,e,d.selectorMaxLength,h,a))}catch(ja){a.call(p,ja,b)}if(void 0===e.verified||e.specificity<d.specificityThreshold)e.verified=D(b,e,d.selectorMaxLength,h,a);return e.verified?e.verificationDepth?E(e,e.verificationDepth):E(e):!1};c.configure=function(){var a=1<arguments.length&&
void 0!==arguments[1]?arguments[1]:b,c=S(T({},d,0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}));return U(a,c,V(a,c.queryEngine))};return c}var sa=function(a){return function(b,c){try{return a.querySelectorAll(b)}catch(d){c(d)}}},V=function(a,b){a=a.document;var c="function"===typeof b?b:sa(a);return function(a,b){return"string"!==typeof a?[]:c(a,b)}},n="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"===typeof Symbol&&
a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},T=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b],d;for(d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},W=1/0,I=0/0,aa=/^\s+|\s+$/g,ea=/^[-+]0x[0-9a-f]+$/i,ba=/^0b[01]+$/i,ca=/^0o[0-7]+$/i,da=parseInt,Z=Object.prototype.toString,ta=function(a,b,c){if(!a||!a.length)return[];c||void 0===b?c=1:((c=b)?(c=e(c),c=c===W||c===-W?1.7976931348623157e+308*(0>c?-1:1):c===c?c:0):c=0===c?c:
0,b=c%1,c=c===c?b?c-b:c:0);b=c;c=0;var d=0>b?0:b;b=-1;var h=a.length;0>c&&(c=-c>h?0:h+c);d=d>h?h:d;0>d&&(d+=h);h=c>d?0:d-c>>>0;c>>>=0;for(d=Array(h);++b<h;)d[b]=a[b+c];return d},m="undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{},la=/^\[object .+?Constructor\]$/,m="object"==n(m)&&m&&m.Object===Object&&m,F="object"==("undefined"===typeof self?"undefined":n(self))&&self&&self.Object===Object&&self,m=m||F||Function("return this")(),F=Array.prototype,
B=Function.prototype,G=Object.prototype,H=m["__core-js_shared__"],N=function(){var a=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}(),R=B.toString,A=G.hasOwnProperty,P=G.toString,ka=RegExp("^"+R.call(A).replace(/[\\^$.*+?()[\]{}|]/g,"\\$\x26").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),B=m.Symbol,oa=G.propertyIsEnumerable,ua=F.splice,Q=B?B.isConcatSpreadable:void 0,X=Math.max,va=L(m,"Map"),w=L(Object,"create");r.prototype.clear=function(){this.__data__=
w?w(null):{}};r.prototype["delete"]=function(a){return this.has(a)&&delete this.__data__[a]};r.prototype.get=function(a){var b=this.__data__;return w?(a=b[a],"__lodash_hash_undefined__"===a?void 0:a):A.call(b,a)?b[a]:void 0};r.prototype.has=function(a){var b=this.__data__;return w?void 0!==b[a]:A.call(b,a)};r.prototype.set=function(a,b){this.__data__[a]=w&&void 0===b?"__lodash_hash_undefined__":b;return this};t.prototype.clear=function(){this.__data__=[]};t.prototype["delete"]=function(a){var b=this.__data__;
a=y(b,a);if(0>a)return!1;a==b.length-1?b.pop():ua.call(b,a,1);return!0};t.prototype.get=function(a){var b=this.__data__;a=y(b,a);return 0>a?void 0:b[a][1]};t.prototype.has=function(a){return-1<y(this.__data__,a)};t.prototype.set=function(a,b){var c=this.__data__,d=y(c,a);0>d?c.push([a,b]):c[d][1]=b;return this};u.prototype.clear=function(){this.__data__={hash:new r,map:new (va||t),string:new r}};u.prototype["delete"]=function(a){return z(this,a)["delete"](a)};u.prototype.get=function(a){return z(this,
a).get(a)};u.prototype.has=function(a){return z(this,a).has(a)};u.prototype.set=function(a,b){z(this,a).set(a,b);return this};x.prototype.add=x.prototype.push=function(a){this.__data__.set(a,"__lodash_hash_undefined__");return this};x.prototype.has=function(a){return this.__data__.has(a)};var wa=function(a,b){b=X(void 0===b?a.length-1:b,0);return function(){for(var c=arguments,d=-1,h=X(c.length-b,0),e=Array(h);++d<h;)e[d]=c[b+d];d=-1;for(h=Array(b+1);++d<b;)h[d]=c[d];h[b]=e;return l(a,this,h)}}(function(a,
b){if(C(a)){b=J(b,1,C,!0);var c=-1,d=Y,h=!0,e=a.length,p=[],f=b.length;if(e)b:for(200<=b.length&&(d=ga,h=!1,b=new x(b));++c<e;){var g=a[c],k=g,g=0!==g?g:0;if(h&&k===k){for(var l=f;l--;)if(b[l]===k)continue b;p.push(g)}else d(b,k,void 0)||p.push(g)}a=p}else a=[];return a}),na=Array.isArray,v={methods:[],getMethods:function(){return this.methods.slice(0)},addMethod:function(a,b){b=b&&"object"===("undefined"===typeof b?"undefined":n(b))?b:this;this.methods.push(a.bind(b))}};v.addMethod(function(a,b,
c,d,h,e){var f;for(f=0;f<a.length&&!b.verified;f+=1){var g=a[f];g=g.el.getAttribute("id");g="string"===typeof g&&null!==g.match(/^[0-9a-zA-Z][a-zA-Z_\-:0-9.]*$/gi)?g:!1;var k;if(k=g)k=1===(h('[id\x3d"'+g+'"]')||[]).length;k&&(b.stack[f].push("[id\x3d'"+g+"']"),b.specificity+=100,0===f?d(a[0],b,c.selectorMaxLength,h,e)?b.verified=!0:(b.stack[f].pop(),b.specificity-=100):b.specificity>=c.specificityThreshold&&d(a[0],b,c.selectorMaxLength,h,e)&&(b.verified=!0))}return b});v.addMethod(function(a,b){var c;
for(c=0;c<a.length;c+=1){var d=a[c];d=d.el.nodeName;d="string"===typeof d&&null!==d.match(/^[a-zA-Z0-9]+$/gi)?d:!1;d&&(b.stack[c].splice(0,0,d),b.specificity+=10)}return b});v.addMethod(function(a,b,c,d,e,f){var h=a[0];switch(h.el.nodeName){case "A":if(h=h.el.getAttribute("href"))b.stack[0].push('A[href\x3d"'+h+'"]'),b.specificity+=10;break;case "IMG":if(h=h.el.getAttribute("src"))b.stack[0].push('IMG[src\x3d"'+h+'"]'),b.specificity+=10;break;default:return b}d(a[0],b,c.selectorMaxLength,e,f)?b.verified=
!0:b.stack[0].pop();return b});v.addMethod(function(a,b){a.forEach(function(a,d){(a=(a.el.getAttribute("class")||"").replace(/^\s\s*/,"").replace(/\s\s*$/,""))&&"string"===typeof a&&(a=ta(a.match(/([^\s]+)/gi)||[],10).filter(k).map(function(a){return"."+a}),a.length&&(b.stack[d].push(a.join("")),b.specificity+=10*a.length))});return b});v.addMethod(function(a,b,c,d,h,e){for(var f=0,g,k;f<a.length&&!b.verified;)g=a[f].prevAll(),k=g.length+1,g=g.concat(a[f].nextAll()),0!==g.length&&(g=this.analyzeElementSiblings(a[f],
g),g||(b.stack[f].push(":nth-child("+k+")"),b.verified=d(a[0],b,c.selectorMaxLength,h,e))),f+=1;return b},{analyzeElementSiblings:function(a,b){var c=a.el.nodeName,d=a.getClasses(),e=!0,f=d[0]instanceof Array&&0<d[0].length,g;for(a=0;a<b.length&&(f||e);a+=1)f=b[a],(g=f.el.nodeName)&&g===c&&(e=!1),f=0<wa(d,f.getClasses()).length;return f||e}});var E=function(a,b){b=b||a.stack.length;var c=[],d=0,f;for(f=b-1;0<=f;--f)0===a.stack[f].length?f!==b-1-d?c.push("*"):d+=1:c.push(a.stack[f].join(""));return c.join(" \x3e ")},
D=function(a,b,c,d,f){for(var e=!1,g=1;g<=b.stack.length&&!e;g+=1){e=E(b,g).trim();if(!e||!e.length||c&&e.length>c)return!1;e=d(e,f);if(e=1===e.length&&(void 0!==a.el?e[0]===a.el:e[0]===a))b.verificationDepth=g}return e},ra={queryEngine:null,specificityThreshold:100,depth:3,errorHandling:!1,selectorMaxLength:512};(function(a,b){var c=a.Simmer;a.Simmer=b;b.noConflict=function(){a.Simmer=c;return b}})(window,U(window))})();

@@ -44,38 +44,2 @@ 'use strict';

this.methods.push(fn.bind(context));
},
// Internal functions for the parsing process
validationHelpers: {
/**
* Validate the syntax of a tagName to make sure that it has a valid syntax for the query engine.
* Many libraries use invalid property and tag names, such as Facebook that use FB: prefixed tags.
* These make the query engines fail and must be filtered out.
* @param {string} tagName. The element's tag name
*/
tagName: function tagName(_tagName) {
if (typeof _tagName === 'string' && _tagName.match(/^[a-zA-Z0-9]+$/gi) !== null) {
return _tagName;
}
return false;
},
/**
* Validate the syntax of an attribute to make sure that it has a valid syntax for the query engine.
* @param {string} attribute. The element's attribute's value
*/
attr: function attr(attribute) {
if (typeof attribute === 'string' && attribute.match(/^[0-9a-zA-Z][a-zA-Z_\-:0-9.]*$/gi) !== null) {
return attribute;
}
return false;
},
/**
* Validate the syntax of an attribute to make sure that it has a valid syntax for the query engine.
* @param {string} attribute. The element's attribute's value
*/
className: function className(_className) {
if (typeof _className === 'string' && _className.match(/^\.?[a-zA-Z_\-:0-9]*$/gi) !== null) {
return _className;
}
return false;
}
}

@@ -82,0 +46,0 @@ };

@@ -11,3 +11,3 @@ 'use strict';

currentElem = hierarchy[index];
currentID = this.validationHelpers.attr(currentElem.el.getAttribute('id')
currentID = (0, _validationHelpers.attr)(currentElem.el.getAttribute('id')
// make sure the ID is unique

@@ -43,2 +43,4 @@ );if (currentID && (0, _queryEngine.isUniqueElementID)(query, currentID)) {

var _queryEngine = require('../queryEngine');
var _queryEngine = require('../queryEngine');
var _validationHelpers = require('./validationHelpers');

@@ -8,31 +8,27 @@ 'use strict';

exports.default = function (hierarchy, state) {
var index, classIndex, currentElem, currentClasses, classes;
for (index = 0; index < hierarchy.length; index += 1) {
currentElem = hierarchy[index];
hierarchy.forEach(function (currentElem, index) {
// get class attribute
currentClasses = currentElem.el.getAttribute('class');
var currentClasses = (currentElem.el.getAttribute('class') || '').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
if (currentClasses && typeof currentClasses === 'string') {
// trim spaces
currentClasses = currentClasses.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
classes = currentClasses.match(/([^\s]+)/gi);
if (classes) {
if (classes.length > 0) {
// add . before the first class
classes[0] = '.' + classes[0];
}
var validClasses = (0, _lodash2.default)(currentClasses.match(/([^\s]+)/gi) || [], 10).filter(_validationHelpers.className).map(function (className) {
return '.' + className;
});
if (validClasses.length) {
// limit to 10 classes
if (classes.length > 10) {
classes.splice(10, classes.length - 10);
}
for (classIndex = 0; classIndex < classes.length; classIndex += 1) {
if (!this.validationHelpers.className(classes[classIndex])) {
classes.splice(classIndex, 1);
}
}
state.stack[index].push(classes.join('.'));
state.specificity += 10 * classes.length;
state.stack[index].push(validClasses.join(''));
state.specificity += 10 * validClasses.length;
}
}
}
});
return state;
};
};
var _lodash = require('lodash.take');
var _lodash2 = _interopRequireDefault(_lodash);
var _validationHelpers = require('./validationHelpers');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

"use strict";
'use strict';

@@ -11,3 +11,3 @@ Object.defineProperty(exports, "__esModule", {

currentElem = hierarchy[index];
currentTag = this.validationHelpers.tagName(currentElem.el.nodeName);
currentTag = (0, _validationHelpers.tagName)(currentElem.el.nodeName);

@@ -21,2 +21,4 @@ if (currentTag) {

return state;
};
};
var _validationHelpers = require('./validationHelpers');

@@ -42,3 +42,3 @@ 'use strict';

var customConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var customQuery = arguments[2];
var customQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

@@ -147,3 +147,3 @@ var config = (0, _configuration.configure)(customConfig);

var newConfig = (0, _configuration.configure)(_extends({}, config, configValues));
return createSimmer(scope, (0, _queryEngine2.default)(scope, newConfig.queryEngine), newConfig);
return createSimmer(scope, newConfig, (0, _queryEngine2.default)(scope, newConfig.queryEngine));
};

@@ -150,0 +150,0 @@

@@ -20,47 +20,2 @@ import inspectElementID from './inspectElementID'

this.methods.push(fn.bind(context))
},
// Internal functions for the parsing process
validationHelpers: {
/**
* Validate the syntax of a tagName to make sure that it has a valid syntax for the query engine.
* Many libraries use invalid property and tag names, such as Facebook that use FB: prefixed tags.
* These make the query engines fail and must be filtered out.
* @param {string} tagName. The element's tag name
*/
tagName: function (tagName) {
if (
typeof tagName === 'string' &&
tagName.match(/^[a-zA-Z0-9]+$/gi) !== null
) {
return tagName
}
return false
},
/**
* Validate the syntax of an attribute to make sure that it has a valid syntax for the query engine.
* @param {string} attribute. The element's attribute's value
*/
attr: function (attribute) {
if (
typeof attribute === 'string' &&
attribute.match(/^[0-9a-zA-Z][a-zA-Z_\-:0-9.]*$/gi) !== null
) {
return attribute
}
return false
},
/**
* Validate the syntax of an attribute to make sure that it has a valid syntax for the query engine.
* @param {string} attribute. The element's attribute's value
*/
className: function (className) {
if (
typeof className === 'string' &&
className.match(/^\.?[a-zA-Z_\-:0-9]*$/gi) !== null
) {
return className
}
return false
}
}

@@ -67,0 +22,0 @@ }

import { isUniqueElementID } from '../queryEngine'
import { attr } from './validationHelpers'
/**

@@ -19,3 +19,3 @@ * Inspect the elements' IDs and add them to the CSS Selector

currentElem = hierarchy[index]
currentID = this.validationHelpers.attr(currentElem.el.getAttribute('id'))
currentID = attr(currentElem.el.getAttribute('id'))
// make sure the ID is unique

@@ -22,0 +22,0 @@ if (currentID && isUniqueElementID(query, currentID)) {

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

import take from 'lodash.take'
import { className as validateClassName } from './validationHelpers'
/**
/**
* Inspect the element's siblings by CSS Class names and compare them to the analyzed element.

@@ -7,33 +10,21 @@ * @param {array} hierarchy. The hierarchy of elements

export default function (hierarchy, state) {
var index, classIndex, currentElem, currentClasses, classes
for (index = 0; index < hierarchy.length; index += 1) {
currentElem = hierarchy[index]
hierarchy.forEach((currentElem, index) => {
// get class attribute
currentClasses = currentElem.el.getAttribute('class')
const currentClasses = (currentElem.el.getAttribute('class') || '')
.replace(/^\s\s*/, '')
.replace(/\s\s*$/, '')
if (currentClasses && typeof currentClasses === 'string') {
// trim spaces
currentClasses = currentClasses
.replace(/^\s\s*/, '')
.replace(/\s\s*$/, '')
classes = currentClasses.match(/([^\s]+)/gi)
if (classes) {
if (classes.length > 0) {
// add . before the first class
classes[0] = '.' + classes[0]
}
const validClasses = take(currentClasses.match(/([^\s]+)/gi) || [], 10)
.filter(validateClassName)
.map(className => `.${className}`)
if (validClasses.length) {
// limit to 10 classes
if (classes.length > 10) {
classes.splice(10, classes.length - 10)
}
for (classIndex = 0; classIndex < classes.length; classIndex += 1) {
if (!this.validationHelpers.className(classes[classIndex])) {
classes.splice(classIndex, 1)
}
}
state.stack[index].push(classes.join('.'))
state.specificity += 10 * classes.length
state.stack[index].push(validClasses.join(''))
state.specificity += 10 * validClasses.length
}
}
}
})
return state
}

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

import { tagName } from './validationHelpers'
/**
/**
* Inspect the elements' Tag names and add them to the calculates CSS selector

@@ -10,3 +13,3 @@ * @param {array} hierarchy. The hierarchy of elements

currentElem = hierarchy[index]
currentTag = this.validationHelpers.tagName(currentElem.el.nodeName)
currentTag = tagName(currentElem.el.nodeName)

@@ -13,0 +16,0 @@ if (currentTag) {

@@ -12,3 +12,3 @@ import initQueryEngine, { wrap } from './queryEngine'

customConfig = {},
customQuery
customQuery = false
) {

@@ -150,4 +150,4 @@ const config = configure(customConfig)

scope,
initQueryEngine(scope, newConfig.queryEngine),
newConfig
newConfig,
initQueryEngine(scope, newConfig.queryEngine)
)

@@ -154,0 +154,0 @@ }

{
"name": "simmerjs",
"description": "A pure Javascript reverse CSS selector engine which calculates a DOM element's unique CSS selector on the current page.",
"version": "0.5.4",
"version": "0.5.5",
"author": "Gidi Meir Morris",

@@ -19,4 +19,5 @@ "main": "lib/simmer.js",

"dependencies": {
"lodash.difference": "^4.5.0",
"lodash.isfunction": "^3.0.8",
"lodash.difference": "^4.5.0"
"lodash.take": "^4.1.1"
},

@@ -23,0 +24,0 @@ "scripts": {

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