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

elements-lite

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elements-lite - npm Package Compare versions

Comparing version 0.3.9 to 0.4.0

tests/val.html

23

dist/index-min.js
/*
MIT License
*/
!function(u,h,v){function f(a,b,c){var d,e={};a=a.replace(C,function(a,b,c,d,f){e["."==b?(e[b="class"]&&(c=e[b]+" "+c),b):"#"==b?"id":c]=f?d.slice(1,-1):d||c;return""})||"div";d=(q[a]||(q[a]=h.createElement(a))).cloneNode(!0).set(e);return c?(m[a]&&d.setAttribute("data-call",a),d):m[a]&&m[a].call(d,b)||d.set(b)}function n(a,b){var c,d=0,e=typeof a;if(a){if("string"==e||"number"==e)a=f.text(a);else if(!("nodeType"in a)&&"length"in a){e=a.length;for(c=h.createDocumentFragment();d<e;)n.call(c,a[d++]);
a=c}a.nodeType&&this.insertBefore(a,(!0===b?this.firstChild:"number"==typeof b?this.childNodes[0>b?this.childNodes.length-b-2:b]:b)||null);a.appendHook&&a.appendHook()}return this}function w(a){return-1<(" "+this.className+" ").indexOf(" "+a+" ")}function x(a){this.className+=this.className?w.call(this,a)?"":" "+a:a;return this}function D(a){this.className=(" "+this.className+" ").replace(" "+a+" "," ").trim();return this}function E(){this.parentNode&&this.parentNode.removeChild(this);Event.removeAll&&
Event.removeAll(this);this.killHook&&this.killHook();this.empty&&this.empty();return this}function J(a){var b,c=a._childs;if(!c)for(a._childs=c=[];b=a.firstChild;)c.push(b),a.removeChild(b);return c}function r(a,b){var c,d=this;if(c=!b&&d.getAttribute("data-call"))d.removeAttribute("data-call"),m[c].call(d);if(c=!b&&d.getAttribute("data-bind"))if(d.getAttribute("lang"),"{"==c.charAt(0)&&(c='txt:"'+c.replace(/"/g,'\\"')+'"'),c="n d p r->d&&("+c.replace(K,"(p['$1']?(r=p['$1'](n,d,$2)||r):(n['$1']=$2.format(d))),")+
"r)",c.fn()(d,a,L))return d;for(d=d.firstChild;d;d=d.nextSibling)1==d.nodeType&&r.call(d,a);return this}function F(a,b,c){var d=0,e=[],f=["_"];b=b.replace(C,function(a,b,c,d){f.push("."==b?"(' '+_.className+' ').indexOf(' "+c+" ')>-1":"#"==b?"_.id=='"+c+"'":"_.getAttribute('"+c+"')"+(d?"=='"+d+"'":""));return""})||"*";b=a.getElementsByTagName(b);for(var g=Fn(f.join("&&"));a=b[d++];)if(g(a)){if(c)return a;e.push(a)}return c?null:e}function s(a){this._nodes=a}function y(a,b){if(a)for(b in e)a[b]=e[b];
return a}function z(a,b,c){q[a]="string"==typeof b?f(b):b;c&&(m[a]=c)}function t(a){function b(a,c,g,h,k,l){for(k=c.length;k<=e[0];)e.shift(),d=d.plugin?d.plugin.done():d.parentNode;g?t.plugins[h]?(d=(new t.plugins[h](d,l)).el,e.unshift(k)):d.append(f.text("text"==h?l:a)):(h&&(d=f(h,0,1).to(d),e.unshift(k)),l&&(k=l.charAt(0),">"==k?(c+" "+l.slice(1)).replace(G,b):"="==k?d.set({"data-bind":l.slice(1)}):d.append(l.replace(/\\([=>:])/g,"$1"))))}var c=h.createDocumentFragment(),d=c,e=[-1];a.replace(G,
b);c=c.childNodes;if(1==c.length)return c[0];e=[];for(d=c.length;d--;)e[d]=c[d];return e}function A(a,b){this.name=b;this.parent=a;this.el=f("div");this.el.plugin=this;return this}function g(a,b){return g[b?B(b):p][a]||a}function B(a){if(!a)return p;a=(a||"").toLowerCase();return g[a]?a:(a=a.split("-")[0],g[a])?a:p}function H(a,b){Object.merge(g[a]||(g[a]={}),b)}var p,q={},m={},I=h.createElement,e=(u.HTMLElement||u.Element||f)[v],C=/([.#:[])([-\w]+)(?:=((["'\/])(?:\\?.)*?\4|[-\w]+)])?]?/g,G=/^([ \t]*)(\:?)((?:(["'\/])(?:\\?.)*?\4|[-\w\:.#\[\]=])+)[ \t]*(.*)$/gm,
K=/[;\s]*(\w+)(?:\s*\:((?:(["'\/])(?:\\?.)*?\3|[-,\s\w])*))?/g,L=f.bindings={txt:function(a,b,c){a.txt(c.format(b))},"class":function(a,b,c,d){a.toggleClass(c,d.fn("_")(b))},html:function(a,b,c){a.innerHTML=c.format(b)},each:function(a,b,c){function d(a){return r.call(a.cloneNode(!0),this)}var e=J(a);c&&a.empty().append(c.map(function(a){return e.map(d,a)}));return a}};u.El=f;e.append=n;e.after=function(a,b){n.call(a.parentNode,this,b?a:a.nextSibling);return this};e.to=function(a,b){n.call(a,this,
b);return this};e.hasClass=w;e.addClass=x;e.rmClass=D;e.toggleClass=function(a,b){1==arguments.length&&(b=!w.call(this,a));return(b?x:D).call(this,a),b};e.empty=function(){for(var a;a=this.firstChild;)E.call(a);return this};e.kill=E;e.on=function(a,b){Event.add(this,a,b);return this};e.non=function(a,b){Event.remove(this,a,b);return this};e.set=function(a){var b,c=typeof a;if(!a)return this;if("string"==c||"number"==c||a.nodeType||"length"in a)n.call(this,a);else for(c in a)b=a[c],"class"==c?x.call(this,
b):b?"string"==typeof b?(this.setAttribute(c,b),"id"!=c&&"name"!=c||"\v"!="v"||this.mergeAttributes(I("<INPUT "+c+'="'+b+'">'),!1)):this[c]=b:this.removeAttribute(c);return this};e.render=r;e.txt=function(a){var b="textContent"in this?"textContent":"innerText";return arguments.length?this[b]=a:this[b]};e.find="\v"!=="v"&&e.querySelector||function(a){return F(this,a,!0)};e.findAll=e.querySelectorAll?function(a){return new s(this.querySelectorAll(a))}:function(a){return new s(F(this,a))};f.wrap=s;s.prototype=
Object.keys(e).reduce(function(a,b){a[b]=function(){for(var a=this._nodes,d=0,f=a.length;d<f;)e[b].apply(a[d++],arguments);return this};return a},{});e===f[v]&&(h.createElement=function(a){return y(I(a))},y(h.body));f[v]=e;f.get=function(a){"string"==typeof a&&(a=h.getElementById(a));return a&&a.to?a:y(a)};z._el=q;z._fn=m;f.cache=z;f.text=function(a){return h.createTextNode(a)};A.prototype.done=function(){f.cache(this.name,this.el.removeChild(this.el.firstChild),r);this.el.plugin=null;return this.parent};
t.plugins={template:A};f.create=f.tpl=function(a){return t(a).render()};f.include=function(a,b,c){b=f.get(a);(new A(null,a)).el.append(f.tpl(b.innerHTML)).plugin.done();b.kill()};f.i18n=g;g.get=B;g.use=function(a){a=B(a);p!=(p=a)&&(g[a]=g[a]||{});return h.documentElement.lang=a};g.add=H;g.def=function(a){Object.each(a,function(b,c){H(c,a)})}}(window,document,"prototype");
!function(u,h,v){function f(a,b,c){var d,e={};a=a.replace(D,function(a,b,c,d,f){e["."==b?(e[b="class"]&&(c=e[b]+" "+c),b):"#"==b?"id":c]=f?d.slice(1,-1):d||c;return""})||"div";d=(q[a]||(q[a]=h.createElement(a))).cloneNode(!0).set(e);return c?(m[a]&&d.setAttribute("data-call",a),d):m[a]&&m[a].call(d,b)||d.set(b)}function n(a,b){var c,d=0,e=typeof a;if(a){if("string"==e||"number"==e)a=f.text(a);else if(!("nodeType"in a)&&"length"in a){e=a.length;for(c=h.createDocumentFragment();d<e;)n.call(c,a[d++]);
a=c}a.nodeType&&this.insertBefore(a,(!0===b?this.firstChild:"number"==typeof b?this.childNodes[0>b?this.childNodes.length-b-2:b]:b)||null);a.appendHook&&a.appendHook()}return this}function w(a){return-1<(" "+this.className+" ").indexOf(" "+a+" ")}function x(a){this.className+=this.className?w.call(this,a)?"":" "+a:a;return this}function E(a){this.className=(" "+this.className+" ").replace(" "+a+" "," ").trim();return this}function F(a,b){1==arguments.length&&(b=!w.call(this,a));return(b?x:E).call(this,
a),b}function G(){this.parentNode&&this.parentNode.removeChild(this);Event.removeAll&&Event.removeAll(this);this.killHook&&this.killHook();this.empty&&this.empty();return this}function y(a,b){var c=this;if(1==arguments.length){if(a&&a.constructor===Object){Object.each(a,function(a,b){y.call(c,b,a)});return}return c.getAttribute(a)}"id"!=a&&"name"!=a&&"type"!=a||"\v"!="v"?c.setAttribute(a,b):c.mergeAttributes(H("<INPUT "+a+'="'+b+'">'),!1)}function L(a){var b,c=a._childs;if(!c)for(a._childs=c=[];b=
a.firstChild;)c.push(b),a.removeChild(b);return c}function r(a,b){var c,d=this;if(c=!b&&d.getAttribute("data-call"))d.removeAttribute("data-call"),m[c].call(d);if(c=!b&&d.getAttribute("data-bind"))if(d.getAttribute("lang"),"{"==c.charAt(0)&&(c='txt:"'+c.replace(/"/g,'\\"')+'"'),c="n d p r->d&&("+c.replace(M,"(p['$1']?(r=p['$1'](n,d,$2)||r):(n['$1']=$2.format(d))),")+"r)",c.fn()(d,a,N))return d;for(d=d.firstChild;d;d=d.nextSibling)1==d.nodeType&&r.call(d,a);return this}function I(a,b,c){var d=0,e=
[],f=["_"];b=b.replace(D,function(a,b,c,d){f.push("."==b?"(' '+_.className+' ').indexOf(' "+c+" ')>-1":"#"==b?"_.id=='"+c+"'":"_.getAttribute('"+c+"')"+(d?"=='"+d+"'":""));return""})||"*";b=a.getElementsByTagName(b);for(var g=Fn(f.join("&&"));a=b[d++];)if(g(a)){if(c)return a;e.push(a)}return c?null:e}function s(a){this._nodes=a}function z(a,b){if(a)for(b in e)a[b]=e[b];return a}function A(a,b,c){q[a]="string"==typeof b?f(b):b;c&&(m[a]=c)}function t(a){function b(a,c,g,h,k,l){for(k=c.length;k<=e[0];)e.shift(),
d=d.plugin?d.plugin.done():d.parentNode;g?t.plugins[h]?(d=(new t.plugins[h](d,l)).el,e.unshift(k)):d.append(f.text("text"==h?l:a)):(h&&(d=f(h,0,1).to(d),e.unshift(k)),l&&(k=l.charAt(0),">"==k?(c+" "+l.slice(1)).replace(J,b):"="==k?d.set({"data-bind":l.slice(1)}):d.append(l.replace(/\\([=>:])/g,"$1"))))}var c=h.createDocumentFragment(),d=c,e=[-1];a.replace(J,b);c=c.childNodes;if(1==c.length)return c[0];e=[];for(d=c.length;d--;)e[d]=c[d];return e}function B(a,b){this.name=b;this.parent=a;this.el=f("div");
this.el.plugin=this;return this}function g(a,b){return g[b?C(b):p][a]||a}function C(a){if(!a)return p;a=(a||"").toLowerCase();return g[a]?a:(a=a.split("-")[0],g[a])?a:p}function K(a,b){Object.merge(g[a]||(g[a]={}),b)}var p,q={},m={},H=h.createElement,e=(u.HTMLElement||u.Element||f)[v],D=/([.#:[])([-\w]+)(?:=((["'\/])(?:\\?.)*?\4|[-\w]+)])?]?/g,J=/^([ \t]*)(\:?)((?:(["'\/])(?:\\?.)*?\4|[-\w\:.#\[\]=])+)[ \t]*(.*)$/gm,M=/[;\s]*(\w+)(?:\s*\:((?:(["'\/])(?:\\?.)*?\3|[-,\s\w])*))?/g,N=f.bindings={txt:function(a,
b,c){a.txt(c.format(b))},"class":function(a,b,c,d){F.call(a,c,d.fn("_")(b))},html:function(a,b,c){a.innerHTML=c.format(b)},each:function(a,b,c){function d(a){return r.call(a.cloneNode(!0),this)}var e=L(a);c&&a.empty().append(c.map(function(a){return e.map(d,a)}));return a}};u.El=f;e.append=n;e.after=function(a,b){n.call(a.parentNode,this,b?a:a.nextSibling);return this};e.to=function(a,b){n.call(a,this,b);return this};e.hasClass=w;e.addClass=x;e.rmClass=E;e.toggleClass=F;e.empty=function(){for(var a;a=
this.firstChild;)G.call(a);return this};e.kill=G;e.on=function(a,b){Event.add(this,a,b);return this};e.non=function(a,b){Event.remove(this,a,b);return this};e.attr=y;e.set=function(a,b,c){if(a)if("object"==typeof a)for(b in a)c=a[b],"class"==b?x.call(this,c):"string"==typeof c?y.call(this,b,c):c||this.removeAttribute(b);else n.call(this,a);return this};e.render=r;e.txt=function(a){var b="textContent"in this?"textContent":"innerText";return arguments.length?this[b]=a:this[b]};e.val=function(a){var b=
this,c=b.type,d=b.options;if(arguments.length)return b.value=a;if("select-multiple"==c){a=[];for(c=0;b=d[c++];)!b.selected||b.disabled||b.parentNode.disabled||a.push(b.value);return a}return"checkbox"!=c&&"radio"!=c||b.checked?b.value||options&&options[b.selectedIndex].value||"on":""};e.find="\v"!=="v"&&e.querySelector||function(a){return I(this,a,!0)};e.findAll=e.querySelectorAll?function(a){return new s(this.querySelectorAll(a))}:function(a){return new s(I(this,a))};f.wrap=s;s.prototype=Object.keys(e).reduce(function(a,
b){a[b]=function(){for(var a=this._nodes,d=0,f=a.length;d<f;)e[b].apply(a[d++],arguments);return this};return a},{});e===f[v]&&(h.createElement=function(a){return z(H(a))},z(h.body));f[v]=e;f.get=function(a){"string"==typeof a&&(a=h.getElementById(a));return a&&a.to?a:z(a)};A._el=q;A._fn=m;f.cache=A;f.text=function(a){return h.createTextNode(a)};B.prototype.done=function(){f.cache(this.name,this.el.removeChild(this.el.firstChild),r);this.el.plugin=null;return this.parent};t.plugins={template:B};f.create=
f.tpl=function(a){return t(a).render()};f.include=function(a,b,c){b=f.get(a);(new B(null,a)).el.append(f.tpl(b.innerHTML)).plugin.done();b.kill()};f.i18n=g;g.get=C;g.use=function(a){a=C(a);p!=(p=a)&&(g[a]=g[a]||{});return h.documentElement.lang=a};g.add=K;g.def=function(a){Object.each(a,function(b,c){K(c,a)})}}(window,document,"prototype");

@@ -5,4 +5,4 @@

/**
* @version 0.3.9
* @date 2014-10-16
* @version 0.4.0
* @date 2014-11-23
* @stability 1 - Experimental

@@ -29,3 +29,3 @@ * @author Lauri Rooden <lauri@rooden.ee>

"class": function(node, data, name, fn) {
node.toggleClass(name, fn.fn("_")(data))
toggleClass.call(node, name, fn.fn("_")(data))
},

@@ -142,6 +142,7 @@ "html": function(node, data, html) {

proto.toggleClass = function(name, force) {
function toggleClass(name, force) {
if (arguments.length == 1) force = !hasClass.call(this, name)
return ( force ? addClass : rmClass ).call(this, name), force
}
proto.toggleClass = toggleClass

@@ -173,35 +174,50 @@ proto.empty = function() {

proto.set = function(args) {
var val
, el = this
, key = typeof args
proto.attr = attr
function attr(key, val) {
var el = this
if (arguments.length == 1) {
if (key && key.constructor === Object) {
Object.each(key, function(val, key) {
attr.call(el, key, val)
})
return
}
return el.getAttribute(key)
}
// Note: IE5-7 doesn't set styles and removes events when you try to set them.
//
// in IE6, a label with a for attribute linked to a select list
// will cause a re-selection of the first option instead of just giving focus.
// http://webbugtrack.blogspot.com/2007/09/bug-116-for-attribute-woes-in-ie6.html
if (!args) return el
if (key == "string" || key == "number" || args.nodeType || "length" in args) append.call(el, args)
else for (key in args) {
val = args[key]
// El uses class
if (key == "class") addClass.call(el, val)
else if (!val) el.removeAttribute(key)
else if (typeof val == "string") {
// Note: IE5-7 doesn't set styles and removes events when you try to set them.
//
// in IE6, a label with a for attribute linked to a select list
// will cause a re-selection of the first option instead of just giving focus.
// http://webbugtrack.blogspot.com/2007/09/bug-116-for-attribute-woes-in-ie6.html
el.setAttribute(key, val)
// there are bug in IE<9 where changed 'name' param not accepted on form submit
// The JScript engine used in IE doesn't recognize vertical tabulation character
// oldIE = "\v" == "v"
//
// IE8 and below also support document.createElement('<P>')
//
// http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/
// http://msdn.microsoft.com/en-us/library/ms536614(VS.85).aspx
// there are bug in IE<9 where changed 'name' param not accepted on form submit
// The JScript engine used in IE doesn't recognize vertical tabulation character
// oldIE = "\v" == "v"
//
// IE8 and below also support document.createElement('<P>')
//
// http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/
// http://msdn.microsoft.com/en-us/library/ms536614(VS.85).aspx
if ((key == "id" || key == "name" || key == "type") && "\v" == "v") {
el.mergeAttributes(createElement('<INPUT '+key+'="' + val + '">'), false)
} else {
el.setAttribute(key, val)
}
}
if ((key == "id" || key == "name") && "\v" == "v") {
el.mergeAttributes(createElement('<INPUT '+key+'="' + val + '">'), false)
proto.set = set
function set(args, key, val) {
var el = this
if (args) {
if (typeof args == "object") for (key in args) {
val = args[key]
// El uses class
if (key == "class") addClass.call(el, val)
else if (typeof val == "string") {
attr.call(el, key, val)
}
} else el[key] = val
else if (!val) el.removeAttribute(key)
}
else append.call(el, args)
}

@@ -216,4 +232,3 @@ return el

if (!childs) {
node._childs = childs = []
for (; child = node.firstChild;) {
for (node._childs = childs = []; child = node.firstChild;) {
childs.push(child);

@@ -248,3 +263,5 @@ node.removeChild(child)

for (node = node.firstChild; node; node = node.nextSibling) {
if (node.nodeType == 1) render.call(node, data)
if (node.nodeType == 1) {
render.call(node, data)
}
}

@@ -270,2 +287,24 @@ return this

proto.val = function(val) {
var el = this
, type = el.type
, opts = el.options
if (arguments.length) {
return el.value = val
}
if (type == "select-multiple") {
for (val = [], type = 0; el = opts[type++];) {
if (el.selected && !el.disabled && !el.parentNode.disabled) val.push(el.value)
}
return val
}
return (type == "checkbox" || type == "radio") && !el.checked ? "" :
el.value ||
options && options[el.selectedIndex].value ||
"on"
}
function findEl(node, sel, first) {

@@ -272,0 +311,0 @@ var el

{
"name": "elements-lite",
"version": "0.3.9",
"version": "0.4.0",
"stability": 1,

@@ -36,28 +36,3 @@ "license": "MIT",

"dist/index-min.js": "index.js"
},
"testling": {
"files": "tests/run-browser.js",
"browsers": [
"ie/6..10",
"ff/3",
"ff/4",
"ff/5",
"ff/20",
"ff/25",
"chrome/4",
"chrome/10",
"chrome/20",
"chrome/30",
"chrome/31",
"opera/10",
"opera/11",
"opera/11.6",
"opera/12",
"opera/16",
"safari/4..6",
"android-browser/4.2",
"iphone/6",
"ipad/6"
]
}
}

@@ -5,8 +5,6 @@ [1]: https://secure.travis-ci.org/litejs/elements-lite.png

[4]: https://coveralls.io/r/litejs/elements-lite
[7]: https://ci.testling.com/litejs/elements-lite.png
[8]: https://ci.testling.com/litejs/elements-lite
@version 0.3.9
@date 2014-10-16
@version 0.4.0
@date 2014-11-23
@stability 1 - Experimental

@@ -121,3 +119,3 @@

[![browser support][7]][8]
It should work IE6 and up but automated testing is currently broken.

@@ -124,0 +122,0 @@

@@ -302,2 +302,18 @@ require("browser-upgrade-lite")

/*
it ("supports declaring a leaf node").
run(function() {
t1 = El.tpl([""
, ":template leaf1"
, " a"
, " b[data-leaf]"
, "div"
, " leaf1"
, " i 1"
, " leaf1"
, " i 2"
].join("\n"))
}).
equal(getString(t1), '<div><a><b data-leaf="data-leaf"><i>1</i></b></a><a><b data-leaf="data-leaf"><i>2</i></b></a></div>').
*/
it ("supports IF binding").

@@ -304,0 +320,0 @@

Sorry, the diff of this file is not supported yet

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