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.4 to 0.3.5

2

dist/index-min.js

@@ -5,3 +5,3 @@ /*

!function(r,g,s){function f(a,b,c){var d,e={};a=a.replace(z,function(a,b,c,d,f){e["."==b?(b="class",e[b]&&(c=e[b]+" "+c),b):"#"==b?"id":c]=(f?d.slice(1,-1):d)||c;return""})||"div";d=(n[a]||(n[a]=g.createElement(a))).cloneNode(!0).set(e);return c?(h[a]&&d.setAttribute("data-call",a),d):h[a]&&h[a].call(d,b)||d.set(b)}function m(a,b){if(a){if("string"==typeof a||"number"==typeof a)a=f.text(a);else if(!("nodeType"in a)&&"length"in a){for(var c=a.length,d=0,e=g.createDocumentFragment();d<c;)m.call(e,a[d++]);
a=e}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 t(a){return RegExp("\\b"+a+"\\b").test(this.className)}function u(a){this.className+=this.className?t.call(this,a)?"":" "+a:a;return this}function A(a){this.className=(" "+this.className+" ").replace(" "+a+" "," ").trim();return this}function B(){this.parentNode&&this.parentNode.removeChild(this);Event.removeAll&&
a=e}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 t(a){return-1<(" "+this.className+" ").indexOf(" "+a+" ")}function u(a){this.className+=this.className?t.call(this,a)?"":" "+a:a;return this}function A(a){this.className=(" "+this.className+" ").replace(" "+a+" "," ").trim();return this}function B(){this.parentNode&&this.parentNode.removeChild(this);Event.removeAll&&
Event.removeAll(this);this.killHook&&this.killHook();this.empty&&this.empty();return this}function F(a){var b,c=a._childs;if(!c)for(a._childs=c=[];b=a.firstChild;)c.push(b),a.removeChild(b);return c}function p(a,b){var c,d=this;if(c=!b&&d.getAttribute("data-call"))d.removeAttribute("data-call"),h[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(G,"(p['$1']?(r=p['$1'](n,d,$2)||r):(n['$1']=$2.format(d))),")+

@@ -8,0 +8,0 @@ "r)",c.fn()(d,a,H))return d;for(d=d.firstChild;d;d=d.nextSibling)1==d.nodeType&&p.call(d,a);return this}function C(a,b,c){var d=0,e=[],f=["_"];b=b.replace(z,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 v(a){this._nodes=a}function w(a,b){if(a)for(b in e)a[b]=e[b];

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

/**
* @version 0.3.4
* @date 2014-09-14
* @version 0.3.5
* @date 2014-09-15
* @stability 1 - Experimental

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

// http://jsperf.com/regexp-indexof-perf/32
// return (" "+this.className+" ").indexOf(" "+name+" ") > -1
return RegExp("\\b" + name + "\\b").test(this.className)
return (" " + this.className + " ").indexOf(" " + name + " ") > -1
}

@@ -169,3 +168,3 @@ proto.hasClass = hasClass

var el = this
el.className = (" "+el.className+" ").replace(" "+name+" "," ").trim()
el.className = (" "+el.className+" ").replace(" "+name+" ", " ").trim()
return el

@@ -172,0 +171,0 @@ }

@@ -33,17 +33,17 @@

!function(root) {
var current;
var currentLang
function i18n(text, lang) {
return (i18n[lang ? getLang(lang) : current][text] || text)
return i18n[ lang ? getLang(lang) : currentLang ][text] || text
}
function getLang(lang) {
if (!lang) return current
lang = (lang||"").toLowerCase()
return i18n[lang] ? lang : (lang = lang.split("-")[0]), i18n[lang] ? lang : current
if (!lang) return currentLang
lang = (lang || "").toLowerCase()
return i18n[lang] ? lang : (lang = lang.split("-")[0]), i18n[lang] ? lang : currentLang
}
function setLang(lang) {
lang = i18n.getLang(lang)
if (current != (current = lang)) {
lang = getLang(lang)
if (currentLang != (currentLang = lang)) {
i18n[lang] = i18n[lang] || {}

@@ -54,28 +54,38 @@ }

setLang("en")
/*
* navigator.language
* "et"
* navigator.languages
* ["et", "en-US", "en"]
*/
i18n.getLang = getLang
i18n.setLang = setLang
i18n.use
i18n.append
//i18n.main = i18n.current = "en"
//i18n.main = i18n.currentLang = "en"
i18n.en = {
date: "%a, %d %b %Y %H:%M:%S %z",
name: "Name {date|lang}"
}
i18n.en = {
date: "%a, %d %b %Y %H:%M:%S %z",
name: "Name {date|lang}"
}
i18n.et = {
date: "%Y %H:%M:%S %z",
name: "Nimi {date|lang:'et'}"
}
i18n.et = {
date: "%Y %H:%M:%S %z",
name: "Nimi {date|lang:'et'}"
}
//i18n.setLang(navigator.language || navigator.userLanguage)
//i18n.setLang(navigator.language || navigator.userLanguage)
Date.prototype.lang = function(lang) {
return this.format( i18n("date", lang) )
}
Date.prototype.lang = function(lang) {
return this.format( i18n("date", lang) )
}
String.prototype.lang = function(lang) {
return i18n(this, lang)
}
String.prototype.lang = function(lang) {
return i18n(this, lang)
}
root.i18n = i18n
}(this)
{
"name": "elements-lite",
"version": "0.3.4",
"version": "0.3.5",
"stability": 1,

@@ -18,2 +18,3 @@ "license": "MIT",

"build": "node node_modules/buildman/index.js --all",
"bundle-tests": "browserify tests/run-browser.js > tests/bundle.js",
"travis-test": "istanbul cover ./tests/run.js && (coveralls < coverage/lcov.info || exit 0)",

@@ -20,0 +21,0 @@ "test": "node tests/run.js"

@@ -9,4 +9,4 @@ [1]: https://secure.travis-ci.org/litejs/elements-lite.png

@version 0.3.4
@date 2014-09-14
@version 0.3.5
@date 2014-09-15
@stability 1 - Experimental

@@ -13,0 +13,0 @@

@@ -5,32 +5,63 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

/*
* @version 0.2.2
* @date 2014-05-24
* @stability 1 - Experimental
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
/**
* @version 0.3.4
* @date 2014-09-14
* @stability 1 - Experimental
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
// TODO: find ways for automated testing
// http://www.browserscope.org/user/tests/howto
/* TODO: find ways for automated testing
* http://www.browserscope.org/user/tests/howto
*/
!function(root, doc, protoStr) {
!function(window, document, protoStr) {
var elCache = {}
, fnCache = {}
, proto = (root.HTMLElement || root.Element || El)[protoStr]
, createElement = document.createElement
, proto = (window.HTMLElement || window.Element || El)[protoStr]
, elRe = /([.#:[])([-\w]+)(?:=((["'\/])(?:\\.|.)*?\4|[-\w]+)])?]?/g
, tplRe = /^([ \t]*)(\:?)((?:(["'\/])(?:\\.|.)*?\4|[-\w\:.#\[\]=])+)[ \t]*(.*)$/gm
, renderRe = /[;\s]*(\w+)(?:\s*\:((?:(["'\/])(?:\\.|.)*?\3|[-,\s\w])*))?/g
, bindings = El.bindings = {
"txt": function(node, data, text) {
node.txt(text.format(data))
},
"class": function(node, data, name, fn) {
node.toggleClass(name, fn.fn("_")(data))
},
"html": function(node, data, html) {
node.innerHTML = html.format(data)
},
/**
"with": function(node, data, scope) {
render.call(node, scope, true)
},
"if": function(node, data, fn) {
var childs = getChilds(node)
node.empty().append( fn.fn("_")(data) && childs )
},
//*/
"each": function(node, data, arr) {
var childs = getChilds(node)
if (arr) node.empty().append(arr.map(function(obj) {
return childs.map(function(el) {
return render.call(el.cloneNode(true), obj)
})
}))
return node
}
}
/*
* Examples:
* - El("input#123.nice[type=checkbox]:checked:disabled[data-lang=en]")
*/
/**
* Turns CSS selector like syntax to DOM Node
* @example
* El("input#123.nice[type=checkbox]:checked:disabled[data-lang=en]")
* @returns {Node}
*/
function El(name, args) {
function El(name, args, silence) {
var el

@@ -40,3 +71,3 @@ , pre = {}

pre[
op == "." ? (op = "class", (pre[op] && (key = pre[op]+" "+key)), op) :
op == "." ? (op = "class", (pre[op] && (key = pre[op] + " " + key)), op) :
op == "#" ? "id" :

@@ -48,81 +79,69 @@ key

/*
* NOTE: IE’s cloneNode operation consolidates the two text nodes together as one
* http://brooknovak.wordpress.com/2009/08/23/ies-clonenode-doesnt-actually-clone/
*/
// NOTE: IE-s cloneNode consolidates the two text nodes together as one
// http://brooknovak.wordpress.com/2009/08/23/ies-clonenode-doesnt-actually-clone/
el = (elCache[name] || (elCache[name] = document.createElement(name))).cloneNode(true).set(pre)
el = (elCache[name] || (elCache[name] = doc.createElement(name))).cloneNode(true).set(pre)
return fnCache[name] && fnCache[name].call(el, args) || el.set(args)
return silence ?
(fnCache[name] && el.setAttribute("data-call", name), el) :
fnCache[name] && fnCache[name].call(el, args) || el.set(args)
}
window.El = El
// TODO: Extend El api
// add El.siblings( [selector ] )
// add El.children( [selector ] )
// add El.invoke
// https://github.com/WebReflection/dom4#dom4
/* TODO: Extend El api
* add El.siblings( [selector ] )
* add El.children( [selector ] )
* add El.invoke
* https://github.com/WebReflection/dom4#dom4
*/
//
// How elements.js extends the DOM
// -------------------------------
//
// All DOM extensions on the element are available by default.
//
// In browsers that does not support adding methods to prototype of native objects
// such as HTMLElement or Element, document.createElement will be overrided
// to extend created elements. El.get() and element.find will extend
// returned elements.
/*
* How elements.js extends the DOM
* -------------------------------
*
* All DOM extensions on the element are available by default.
*
* In browsers that does not support adding methods to prototype of native objects
* such as HTMLElement or Element, document.createElement will be overrided
* to extend created elements. El.get() and element.find will extend
* returned elements.
*/
// ### element.append( content, [ before ] ) -> element
//
// - **content** `element || Array || String || Number`
// - **before** `optional`
// - true - Insert content to the beginning of element
// - element - Insert content before specified element
// - Number - Insert content before nth child
/*
* ### element.append( content, [ before ] ) -> element
*
* - **content** `element || Array || String || Number`
* - **before** `optional`
* - true - Insert content to the beginning of element
* - element - Insert content before specified element
* - Number - Insert content before nth child
*/
proto.append = function(child, before) {
var t = this
if (child) {
function append(child, before) {
var el = this
if (child) {
if (typeof child == "string" || typeof child == "number") child = El.text(child)
else if ( !("nodeType" in child) && "length" in child ) {
/*
* document.createDocumentFragment is unsupported in IE5.5
* fragment = "createDocumentFragment" in doc ? doc.createDocumentFragment() : El("div")
*/
// document.createDocumentFragment is unsupported in IE5.5
// fragment = "createDocumentFragment" in document ? document.createDocumentFragment() : El("div")
for (
var len = child.length
, i = 0
, fragment = doc.createDocumentFragment();
i < len
; ) proto.append.call(fragment, child[i++]);
, fragment = document.createDocumentFragment();
i < len; ) append.call(fragment, child[i++]);
child = fragment
}
if (child.nodeType) t.insertBefore(child,
(before === true ? t.firstChild :
typeof before == "number" ? t.childNodes[
before < 0 ? t.childNodes.length - before - 2 : before
if (child.nodeType) el.insertBefore(child,
(before === true ? el.firstChild :
typeof before == "number" ? el.childNodes[
before < 0 ? el.childNodes.length - before - 2 : before
] : before) || null
)
child.append_hook && child.append_hook()
//"child_hook" in t && t.child_hook()
if (child.appendHook) child.appendHook()
//"childHook" in el && el.childHook()
}
return t
return el
}
proto.append = append
proto.after = function(silbing, before) {
/*
* call append from proto so it works with DocumentFragment
*/
proto.append.call(silbing.parentNode, this, before ? silbing : silbing.nextSibling)
// call append so it works with DocumentFragment
append.call(silbing.parentNode, this, before ? silbing : silbing.nextSibling)
return this

@@ -132,46 +151,46 @@ }

proto.to = function(parent, before) {
proto.append.call(parent, this, before)
append.call(parent, this, before)
return this
}
proto.hasClass = function(name) {
/*
* http://jsperf.com/regexp-indexof-perf/32
* return (" "+this.className+" ").indexOf(" "+name+" ") > -1
*/
function hasClass(name) {
// http://jsperf.com/regexp-indexof-perf/32
// return (" "+this.className+" ").indexOf(" "+name+" ") > -1
return RegExp("\\b" + name + "\\b").test(this.className)
}
proto.hasClass = hasClass
proto.addClass = function(name) {
var t = this
t.className += t.className == "" ? name : t.hasClass(name) ? "" : " " + name
return t
function addClass(name) {
var el = this
el.className += !el.className ? name : hasClass.call(el, name) ? "" : " " + name
return el
}
proto.addClass = addClass
proto.rmClass = function(name) {
var t = this
t.className = (" "+t.className+" ").replace(" "+name+" "," ").trim()
return t
function rmClass(name) {
var el = this
el.className = (" "+el.className+" ").replace(" "+name+" "," ").trim()
return el
}
proto.rmClass = rmClass
proto.toggleClass = function(name, force) {
if (arguments.length == 1) force = !this.hasClass(name)
this[ force ? "addClass" : "rmClass" ](name)
return force
if (arguments.length == 1) force = !hasClass.call(this, name)
return ( force ? addClass : rmClass ).call(this, name), force
}
proto.empty = function() {
var t = this, node
while (node = t.firstChild) t.kill.call(node)
return t
for (var node, el = this; node = el.firstChild; ) kill.call(node)
return el
}
proto.kill = function() {
var t = this
t.parentNode && t.parentNode.removeChild(t)
Event.removeAll && Event.removeAll(t)
t.kill_hook && t.kill_hook()
t.empty && t.empty()
return t
function kill() {
var el = this
if (el.parentNode) el.parentNode.removeChild(el)
if (Event.removeAll) Event.removeAll(el)
if (el.killHook) el.killHook()
if (el.empty) el.empty()
return el
}
proto.kill = kill

@@ -188,105 +207,156 @@ proto.on = function(ev, fn) {

proto.set = function(args, val) {
var t = this
proto.set = function(args) {
var val
, el = this
, key = typeof args
if (args) {
if (key == "string" || key == "number" || args.nodeType || "length" in args) t.append(args)
else for (key in args)
/** hasOwnProperty
if (args.hasOwnProperty(arg))
//*/
{
val = args[key]
// El uses class
if (key == "class") t.addClass(val)
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
*/
t.setAttribute(key, val)
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 == "name" && "\v" == "v") {
t.mergeAttributes(doc.createElement("<INPUT name='" + key + "'/>"), false)
}
if ((key == "id" || key == "name") && "\v" == "v") {
el.mergeAttributes(createElement('<INPUT '+key+'="' + val + '"/>'), false)
}
} else el[key] = val
}
return el
}
}
else if (!val) t.removeAttribute(key)
else t[key] = val
// Save node initial content for later use
function getChilds(node) {
var child
, childs = node._childs
if (!childs) {
node._childs = childs = []
for (; child = node.firstChild;) {
childs.push(child);
node.removeChild(child)
}
}
return t
return childs
}
function render(data, skipSelf) {
var bind, fn, lang
, node = this
/*
* In Safari 2.x, innerText functions properly only
* if an element is neither hidden (via style.display == "none")
* nor orphaned from the document.
* Otherwise, innerText results in an empty string.
*
* textContent is suported from IE9
*
* Opera 9-10 have Node.text, Node.textContent
*/
if (bind = !skipSelf && node.getAttribute("data-call")) {
node.removeAttribute("data-call")
fnCache[bind].call(node)
}
if (bind = !skipSelf && node.getAttribute("data-bind")) {
lang = node.getAttribute("lang") || lang
// HACK: allow .el ={name} short syntax
if (bind.charAt(0) == "{") bind='txt:"' + bind.replace(/"/g, '\\"') + '"'
// i18n(bind, lang).format(data)
// document.documentElement.lang
// document.getElementsByTagName('html')[0].getAttribute('lang')
fn = "n d p r->d&&(" + bind.replace(renderRe, "(p['$1']?(r=p['$1'](n,d,$2)||r):(n['$1']=$2.format(d))),") + "r)"
if (fn.fn()(node, data, bindings)) return node
}
for (node = node.firstChild; node; node = node.nextSibling) {
if (node.nodeType == 1) render.call(node, data)
}
return this
}
proto.render = render
// In Safari 2.x, innerText functions properly only
// if an element is neither hidden (via style.display == "none")
// nor orphaned from the document.
// Otherwise, innerText results in an empty string.
//
// textContent is suported from IE9
//
// Opera 9-10 have Node.text, Node.textContent
proto.txt = function(newText) {
var t = this
, attr = "textContent" in t ? "textContent" : "innerText"
return arguments.length ? (t[attr] = newText) : t[attr]
var el = this
, attr = "textContent" in el ? "textContent" : "innerText"
return arguments.length ? (el[attr] = newText) : el[attr]
}
/*
* Expose slow find for testing
*
* TODO: look another way
* http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed
*/
// NOTE: fast selectors for IE
// http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed
proto._find = function(sel) {
function findEl(node, sel, first) {
var el
, i = 0
, out = []
, rules = ["_"]
, tag = sel.replace(elRe, function(_, o, s, v) {
rules.push(
o == "." ? "(' '+_.className+' ').indexOf(' "+s+" ')>-1" :
o == "#" ? "_.id=='"+s+"'" :
"_.getAttribute('"+s+"')"+(v?"=='"+v+"'":"")
)
return ""
}) || "*"
, els = this.getElementsByTagName(tag)
, fn = Function("_", "return " + rules.join("&&"))
rules.push(
o == "." ? "(' '+_.className+' ').indexOf(' "+s+" ')>-1" :
o == "#" ? "_.id=='"+s+"'" :
"_.getAttribute('"+s+"')"+(v?"=='"+v+"'":"")
)
return ""
}) || "*"
, els = node.getElementsByTagName(tag)
, fn = Fn(rules.join("&&"))
while (el = els[i++]) {
if (fn(el)) {
return el.to ? el : extend(el)
}
for (; el = els[i++]; ) if (fn(el)) {
if (first) return el
out.push(el)
}
return first ? null : out
}
proto.find = doc.querySelector ?
// Note: IE8 don't support :disabled
proto.find = "\v" !== "v" && proto.querySelector || function(sel) {
return findEl(this, sel, true)
}
proto.findAll = proto.querySelectorAll ?
function(sel) {
/*
* Note: IE8 don't support :disabled
*/
return this.querySelector(sel)
} : proto._find
return new ElAll(this.querySelectorAll(sel))
} :
function(sel) {
return new ElAll(findEl(this, sel))
}
// TODO:2014-09-13:lauri:Expose ElAll
function ElAll(nodes) {
this._nodes = nodes
}
ElAll.prototype = Object.keys(proto).reduce(function(memo, key) {
memo[key] = function() {
var elAll = this
, nodes = elAll._nodes
, i = 0
, len = nodes.length
for (; i < len; ) {
proto[key].apply(nodes[i++], arguments)
}
return elAll
}
return memo
}, {})
function extend(node, key) {

@@ -298,19 +368,13 @@ if (node) for (key in proto) node[key] = proto[key]

// IE 6-7
if (proto === El[protoStr]) {
/*
* IE 6-7
*/
document.createElement = function(name) {return extend(createElement(name))}
var create = doc.createElement
doc.createElement = function(name) {return extend(create(name))}
// NOTE: document.body will not get extended with later added extensions
extend(document.body)
extend(doc.body)
/*
* Remove background image flickers on hover in IE6
*
* You could also use CSS
* html { filter: expression(document.execCommand("BackgroundImageCache", false, true)); }
*/
// Remove background image flickers on hover in IE6
//
// You could also use CSS
// html { filter: expression(document.execCommand("BackgroundImageCache", false, true)); }
/*@cc_on try{document.execCommand('BackgroundImageCache',false,true)}catch(e){}@*/

@@ -321,9 +385,8 @@ }

El.get = function(id) {
if (typeof id == "string") id = doc.getElementById(id)
if (typeof id == "string") id = document.getElementById(id)
return id && id.to ? id : extend(id)
}
El.cache = function(name, el, custom) {
function elCacheFn(name, el, custom) {
elCache[name] = typeof el == "string" ? El(el) : el

@@ -334,41 +397,14 @@ if (custom) {

}
El.cache.el = elCache
El.cache.fn = fnCache
El.text = function(str) {
return doc.createTextNode(str)
}
root.El = El
}(window, document, "prototype")
elCacheFn._el = elCache
elCacheFn._fn = fnCache
El.cache = elCacheFn
},{}],2:[function(require,module,exports){
/*
* @version 0.2.2
* @date 2014-05-24
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
!function(root, doc) {
var hamlRe = /^([ \t]*)(\:?)((?:(["'\/])(?:\\.|.)*?\4|[-\w\:.#\[\]=])+)[ \t]*(.*)$/gm
function to_array(a) {
for (var b=[], c=a.length; c--;) b[c] = a[c]
return b
El.text = function(str) {
return document.createTextNode(str)
}
function This() {
return this
}
function haml(str) {
var root = doc.createDocumentFragment()
function tpl(str) {
var root = document.createDocumentFragment()
, parent = root

@@ -384,24 +420,31 @@ , stack = [-1]

if (plugin) {
if (haml.plugins[name]) {
parent = (new haml.plugins[name](parent, text)).el
if (tpl.plugins[name]) {
parent = (new tpl.plugins[name](parent, text)).el
stack.unshift(i)
} else {
parent.append(El.text( name == "text" ? text : all ))
}
else {
parent.append(El.text( all ))
}
} else {
if (name) {
parent = El(name).to(parent)
parent = El(name, 0, 1).to(parent)
stack.unshift(i)
}
if (text) {
if (text.charAt(0)==">") (indent +" "+ text.slice(1)).replace(hamlRe, work)
else if (text.charAt(0)=="=") parent.set({"data-bind": text.slice(1)})
else parent.append(text.replace(/\\([=>:])/g, "$1"))
q = text.charAt(0)
if (q == ">") {
(indent +" "+ text.slice(1)).replace(tplRe, work)
} else if (q == "=") {
parent.set({"data-bind": text.slice(1)})
} else {
parent.append(text.replace(/\\([=>:])/g, "$1"))
}
}
}
}
str.replace(hamlRe, work)
stack = root.childNodes
return stack.length == 1 ? stack[0] : to_array(stack)
str.replace(tplRe, work)
root = root.childNodes
if (root.length == 1) return root[0]
for (stack = [], parent = root.length; parent--;) stack[parent] = root[parent]
return stack
}

@@ -418,127 +461,45 @@

template.prototype = {
cloneNode: This,
set: This,
done: function() {
var t = this
template.prototype.done = function() {
var t = this
El.cache(t.name, t.el.removeChild(t.el.firstChild), render)
El.cache(t.name, t.el.removeChild(t.el.firstChild), render)
t.el.plugin = null
t.el.plugin = null
return t.parent
}
return t.parent
}
var ifFn = template.extend({
done: function(){
var t = this
El.cache(t.name, t.el.firstChild, render)
t.el.plugin = null
return t.parent
}
})
haml.plugins = {
tpl.plugins = {
/*
* - Declaration
* mixin list
*
* mixin link(href, name)
* a(class!=attributes.class, href=href)= name
*
* +link('/foo', 'foo')(class="btn")
*
* :include
* :doctype
* - http://stackoverflow.com/questions/8227612/how-to-create-document-objects-with-javascript
*/
"template": template,
"if": ifFn,
"for": function(parent, name, text) {
}
* - Declaration
* mixin list
*
* mixin link(href, name)
* a(class!=attributes.class, href=href)= name
*
* +link('/foo', 'foo')(class="btn")
*
* :include
* :doctype
* - http://stackoverflow.com/questions/8227612/how-to-create-document-objects-with-javascript
*/
"template": template
}
root.haml = haml
root.include = function(id, data, parent) {
El.tpl = function(str) {
return tpl(str).render()
}
El.include = function(id, data, parent) {
var src = El.get(id)
new template(null, id).el.append( El.haml(src.innerHTML) ).plugin.done()
new template(null, id).el.append( El.tpl(src.innerHTML) ).plugin.done()
src.kill()
}
}(window, document, "prototype")
function getLa(node) {
var la = node.la
if (!la) {
node.la = la = []
for (var child; child = node.firstChild;) {
la.push(child);
node.removeChild(child)
}
}
return la
}
var attrMap = {
"text": "textContent" in doc ? "textContent" : "innerText",
"html": "innerHTML",
"if": function(node, data, bind) {
console.log("if", arguments)
var la = getLa(node)
var arr = data && data[bind]
if (arr) node.empty().append( Fn(bind)(data) && arr )
},
"each": function(node, data, bind) {
var la = getLa(node)
var arr = data && data[bind]
if (arr) node.empty().append(arr.map(function(obj){
return la.map(function(el){
return render.call(el.cloneNode(true), obj)
})
}))
}
}
function render(data) {
var attr, bind, lang
, node = this
},{}],2:[function(require,module,exports){
//console.log("render", data, node)
if (bind = node.getAttribute("data-bind")) {
lang = node.getAttribute("lang") || lang
if (attr = bind.match(/(\w+)\:/)) {
bind = bind.slice( attr[0].length )
attr = attrMap[attr[1]] || attr[1]
}
if (typeof attr == "function") {
attr(node, data, bind)
return node
}
else {
node[ attr || attrMap.text ] = i18n(bind, lang).format(data)
}
}
for (node = node.firstChild; node; node = node.nextSibling) {
if (node.nodeType == 1) render.call(node, data)
}
return this
}
root.prototype.render = render
}(window.El || this, window.document)
},{}],3:[function(require,module,exports){
/*

@@ -554,5 +515,20 @@ * @version 0.2.2

/*
* In IE6, most of the choices in the Language Preference list specified a locale-neutral two letter code.
* For instance fr was sent for French (France), and ja sent for Japanese.
* Longer codes were only used when a language is commonly spoken in another country or locale-- for instance fr-CA was available for French-speaking Canadians.
*
* For Internet Explorer 7, a change was made such that Internet Explorer will send the full language/locale pair for each locale.
* IE7 will send fr-FR for French (France) and de-DE for German (Germany).
* This change enables web servers to more easily target content for a specific language and locale.
* If a given server is only interested in the user’s language and not the locale, it can ignore the locale portion by simply truncating the code at the first dash.
*
* Anyway, it's always more user-friendly to use Accept-Language than IP-address-based Geo-Location.
*
* Accept-Language: eo;q=0
* the q stands for "quality" and denotes a preference where 1 is highest and 0 means "not acceptable".
* means "I can't read or understand Esperanto and no, please do not provide any content in that language."
*/
!function(root) {

@@ -607,3 +583,3 @@ var current;

},{}],4:[function(require,module,exports){
},{}],3:[function(require,module,exports){

@@ -613,5 +589,5 @@

/*
* @version 0.1.8
* @date 2014-02-18
* @stability 2 - Unstable
* @version 1.1.0
* @date 2014-09-12
* @stability 3 - Stable
* @author Lauri Rooden <lauri@rooden.ee>

@@ -624,15 +600,13 @@ * @license MIT License

!function(win) {
var a, b
, c = Object
!function(window) {
var a, b, c, O
, P = "prototype"
, A = Array[P]
, S = String[P]
, F = Function
, esc = escape
, patched = win._patched = []
, patched = window._patched = []
function I(obj, key, src, force) {
if (force || !obj[key]) {
obj[key] = new F("a,b,c","var P='"+P+"';"+src)
function add(key, src) {
if (!O[key]) {
O[key] = new F("a,b,c","var P='"+P+"';"+src)
patched.push(key)

@@ -656,3 +630,4 @@ }

*/
I(F[P], "bind", "var t=this;b=[].slice.call(arguments,1);c=function(){return t.apply(this instanceof c?this:a,b.concat.apply(b,arguments))};if(t[P])c[P]=t[P];return c")
O = F[P]
add("bind", "var t=this;b=[].slice.call(arguments,1);c=function(){return t.apply(this instanceof c?this:a,b.concat.apply(b,arguments))};if(t[P])c[P]=t[P];return c")

@@ -663,4 +638,5 @@

I(c, "create" , "b=Function.Nop;b[P]=a;return new b")
I(c, "keys" , "c=[];for(b in a)a.hasOwnProperty(b)&&c.push(b);return c")
O = Object
add("create" , "b=Function.Nop;b[P]=a;return new b")
add("keys" , "c=[];for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&c.push(b);return c")

@@ -673,28 +649,34 @@

I(Array, "isArray", "return a instanceof Array")
O = Array
add("isArray", "return a instanceof Array")
O = O[P]
a = "var t=this,l=t.length,o=[],i=-1;"
c = "if(t[i]===a)return i;return -1"
I(A, "indexOf", a+"i+=b|0;while(++i<l)"+c)
I(A, "lastIndexOf", a+"i=(b|0)||l;i>--l&&(i=l)||i<0&&(i+=l);++i;while(--i>-1)"+c)
add("indexOf", a+"i+=b|0;while(++i<l)"+c)
add("lastIndexOf", a+"i=(b|0)||l;i>--l&&(i=l)||i<0&&(i+=l);++i;while(--i>-1)"+c)
b = a+"if(arguments.length<2)b=t"
c = "b=a.call(null,b,t[i],i,t);return b"
I(A, "reduce", b+"[++i];while(++i<l)"+c)
I(A, "reduceRight", b+"[--l];i=l;while(i--)"+c)
add("reduce", b+"[++i];while(++i<l)"+c)
add("reduceRight", b+"[--l];i=l;while(i--)"+c)
b = a+"while(++i<l)if(i in t)"
I(A, "forEach", b+"a.call(b,t[i],i,t)")
I(A, "every", b+"if(!a.call(b,t[i],i,t))return!1;return!0")
add("forEach", b+"a.call(b,t[i],i,t)")
add("every", b+"if(!a.call(b,t[i],i,t))return!1;return!0")
c = ";return o"
I(A, "map", b+"o[i]=a.call(b,t[i],i,t)"+c)
add("map", b+"o[i]=a.call(b,t[i],i,t)"+c)
b += "if(a.call(b,t[i],i,t))"
I(A, "filter", b+"o.push(t[i])"+c)
I(A, "some", b+"return!0;return!1")
add("filter", b+"o.push(t[i])"+c)
add("some", b+"return!0;return!1")
I(S, "trim", "return this.replace(/^\\s+|\\s+$/g, '')")
O = String[P]
add("trim", "return this.replace(/^\\s+|\\s+$/g, '')")
O = Date
add("now", "return+new Date")
/*

@@ -704,13 +686,13 @@ * `Date.prototype.format` is implemented in `date-format-lite` module.

I(Date[P], "toISOString", "return this.format('isoUtcDateTime')")
O = O[P]
add("toISOString", "return this.format('isoUtcDateTime')")
I(Date, "now", "return+new Date")
if (!win.JSON) {
if (!window.JSON) {
patched.push("JSON")
win.JSON = {
window.JSON = {
map: {"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t",'"':'\\"',"\\":"\\\\"},
parse: new F("t", "return new Function('return('+t+')')()"),
//parse: Fn("t->new Function('return('+t+')')()"),
stringify: new F("o", "if(o==null)return'null';if(o instanceof Date)return'\"'+o.toISOString()+'\"';var i,s=[],c;if(Array.isArray(o)){for(i=o.length;i--;s[i]=JSON.stringify(o[i]));return'['+s.join()+']'}c=typeof o;if(c=='string'){for(i=o.length;c=o.charAt(--i);s[i]=JSON.map[c]||(c<' '?'\\\\u00'+((c=c.charCodeAt(0))|4)+(c%16).toString(16):c));return'\"'+s.join('')+'\"'}if(c=='object'){for(i in o)o.hasOwnProperty(i)&&s.push(JSON.stringify(i)+':'+JSON.stringify(o[i]));return'{'+s.join()+'}'}return''+o")
stringify: new F("o", "if(o==null)return'null';if(o instanceof Date)return'\"'+o.toISOString()+'\"';var i,s=[],c;if(Array.isArray(o)){for(i=o.length;i--;s[i]=JSON.stringify(o[i]));return'['+s.join()+']'}c=typeof o;if(c=='string'){for(i=o.length;c=o.charAt(--i);s[i]=JSON.map[c]||(c<' '?'\\\\u00'+((c=c.charCodeAt(0))|4)+(c%16).toString(16):c));return'\"'+s.join('')+'\"'}if(c=='object'){for(i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(JSON.stringify(i)+':'+JSON.stringify(o[i]));return'{'+s.join()+'}'}return''+o")
}

@@ -723,3 +705,3 @@ }

patched.push("escape")
win.escape = function(s) {
window.escape = function(s) {
return esc(s)

@@ -734,26 +716,27 @@ }

},{}],5:[function(require,module,exports){
},{}],4:[function(require,module,exports){
/*
* @version 0.2.3
* @date 2014-02-28
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
/**
* @version 0.2.8
* @date 2014-08-24
* @stability 2 - Unstable
* @author Lauri Rooden <lauri@rooden.ee>
* @license MIT License
*/
!function(root) {
!function(exports) {
var P = "prototype"
, A = Array[P], F = Function[P], S = String[P]
, O = Object
, sl = F.call.bind(A.slice)
, cs = []
, hasOwn = O[P].hasOwnProperty
, slice = F.call.bind(A.slice)
, constructFns = []
, fnRe = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|this|arguments|\.\w+|\w+:/g
// Function extensions

@@ -764,19 +747,22 @@ // -------------------

F.construct = function(a) {
/*
* bind version have bad performance and memory consumption
* return new(F.bind.apply(this, A.concat.apply([null], a)))
*/
var l = a.length
return l ? (cs[l] || (cs[l] = Fn("t a->new t(a["+O.keys(sl(a)).join("],a[")+"])")))(this, a) : new this
// bind version have bad performance and memory consumption
// return new(F.bind.apply(this, A.concat.apply([null], a)))
var len = a.length
return len ?
(constructFns[len] || (constructFns[len] = Fn("t a->new t(a["+O.keys(slice(a)).join("],a[")+"])")))(this, a) :
new this
}
F.partial = function() {
var self = this, a = sl(arguments)
return function() {return self.apply(this, a.concat.apply(a, arguments))}
var self = this
, a = slice(arguments)
return function() {
return self.apply(this, a.concat.apply(a, arguments))
}
}
/*
* **argi** - index of argument, which will be split
* **re** - optional RegExp for matching words
*/
* **argi** - index of argument, which will be split
* **re** - optional RegExp for matching words
*/

@@ -800,3 +786,5 @@ F.byWords = function(argi, re) {

return function(o) {
var r, s = this, a = sl(arguments)
var r
, s = this
, a = slice(arguments)
if (typeof o == "object") for (r in o) {

@@ -818,3 +806,3 @@ a[0] = r

, i = !!instance || this instanceof f
, k = keyFn ? keyFn.apply(self, a) : i + ":" + a.length + ":" + sl(a)
, k = keyFn ? keyFn.apply(self, a) : i + ":" + a.length + ":" + slice(a)

@@ -837,51 +825,16 @@ return k in c ? c[k] : (c[k] = i ? self.construct(a) : self.apply(this, a))

, i = 0
, f = function() {
function f() {
return self.apply(this, arguments)
}
f[P] = O.create(self[P])
for (f[P] = O.create(self[P]); a = arguments[i++];) O.merge(f[P], a)
f[P].constructor = f
while (a = arguments[i++]) O.merge(f[P], a)
return f
}
// Time to live - Run *fun* if Function not called on time
F.ttl = function(ms, fun) {
var self = this
, tick = setTimeout(function(){ms=0;fun&&fun()}, ms)
return function() {
clearTimeout(tick)
ms && self.apply(null, arguments)
}
}
// Run Function one time after last call
F.once = function(ms) {
var tick, args, self = this
return function() {
clearTimeout(tick)
args = arguments
tick = setTimeout(function(){self.apply(null, args)}, ms)
}
}
// Maximum call rate for Function
F.rate = function(ms, last_call) {
var tick, args, self = this, next = 0
return function() {
var now = +new Date()
clearTimeout(tick)
if (now > next) {
next = now + ms
self.apply(null, arguments)
} else if (last_call) {
args = arguments
tick = setTimeout(function(){self.apply(null, args)}, next-now)
}
}
}
// Non-standard
O.each = function(obj, fn, scope, key) {
if (obj) for (key in obj) obj.hasOwnProperty(key) && fn.call(scope, obj[key], key, obj)
if (obj) for (key in obj) hasOwn.call(obj, key) && fn.call(scope, obj[key], key, obj)
}

@@ -892,4 +845,4 @@

O.merge = function(target, source) {
for (var k, i = 1; source = arguments[i++];)
for (k in source) if (source.hasOwnProperty(k)) target[k] = source[k]
for (var key, i = 1; source = arguments[i++];)
for (key in source) if (hasOwn.call(source, key)) target[key] = source[key]
return target

@@ -909,3 +862,3 @@ }

temp = {}
for (key in source) if (source.hasOwnProperty(key))
for (key in source) if (hasOwn.call(source, key))
temp[key] = O.clone(source[key])

@@ -921,9 +874,9 @@ source = temp

for (key in source) if (source.hasOwnProperty(key) && target[key] !== source[key]) {
for (key in source) if (hasOwn.call(source, key) && target[key] !== source[key]) {
val = source[key]
changed.push(path+key)
changed.push(path + key)
if (val === null) delete target[key]
else if (isObject(val)) {
if (!isObject(target[key])) target[key] = {}
O.deepMerge(target[key], val, path+key+".", changed)
O.deepMerge(target[key], val, path + key + ".", changed)
}

@@ -953,9 +906,9 @@ else target[key] = val

A.remove = function() {
var self = this
, l = self.length
, o = sl(arguments)
, last_id = -1
var arr = this
, len = arr.length
, o = slice(arguments)
, lastId = -1
while (l--) if (~o.indexOf(self[l])) self.splice(last_id = l, 1)
return last_id
for (;len--;) if (~o.indexOf(arr[len])) arr.splice(lastId = len, 1)
return lastId
}

@@ -967,4 +920,9 @@

// uniq
A.unique = A.filter.partial(function(s,i,a){return i == a.lastIndexOf(s)})
// last item preserved
A.uniq = A.filter.partial(function(s,i,a){return i == a.lastIndexOf(s)})
A.pushUniq = function(item) {
return this.indexOf(item) == -1 ? this.push(item) : false
}
!function(n) {

@@ -983,25 +941,22 @@ F[n] = S[n] = function() {

S.fn = function() {
return Fn(this)
S.fn = function(scope) {
return Fn(this, scope)
}
/*
* Copyright 2007 by Oliver Steele. MIT License
* http://osteele.com/javascripts/functional
* Modifyed by Lauri Rooden
*/
function Fn(expr) {
var args = "_"
, body = expr
, arr = expr.split("->")
while (arr.length > 1) {
// THANKS: Oliver Steele http://www.osteele.com/sources/javascript/functional/
function Fn(expr, scope) {
for (var args = "_", body = expr, arr = expr.split("->"); arr.length > 1; ) {
body = arr.pop()
args = arr.pop().match(/\w+/g)||""
arr.length && arr.push("(function("+args+"){return("+body+")})")
args = arr.pop().match(/\w+/g) || ""
if (arr.length) arr.push("(function("+args+"){return("+body+")})")
}
return new Function(args, "return(" + body + ")")
// `replace` removes symbols that follow '.',
// precede ':', are 'this' or 'arguments'; and also the insides of
// strings (by a crude test). `match` extracts the remaining
// symbols.
return new Function(args, (scope && (expr = expr.replace(fnRe, "").match(/\b[a-z]\w*|\b_\w+/g)) ?
"var " + expr.uniq().join("='',") + "='';with(" + scope + "||{})" : "") + "return(" + body + ")")
}
root.Fn = Fn.cache()
exports.Fn = Fn.cache()

@@ -1013,3 +968,3 @@ }(this)

},{}],6:[function(require,module,exports){
},{}],5:[function(require,module,exports){

@@ -1019,4 +974,4 @@

/*
* @version 0.0.7
* @date 2014-03-16
* @version 0.1.0
* @date 2014-08-24
* @stability 2 - Unstable

@@ -1034,16 +989,19 @@ * @author Lauri Rooden <lauri@rooden.ee>

, S = String[P]
, formatRe = /\{(?!\\)\s*([$\w]+)((?:(["'\/])(?:\\.|.)*?\3|\-?\d*\.?\d+|[,\s\w|:])*)\}/g
, filterRe = /\s*\|\s*(\w+)(?:\s*\:((?:(["'\/])(?:\\.|.)*?\3|\-?\d*\.?\d+|[,\s])*))?/g
, formatRe = /\{(?!\\)(.+?)\}/g
, filterRe = /\|\s*(\w+)(?:\s*\:((?:(["'\/])(?:\\.|.)*?\3|\-?\d*\.?\d+|[,\s])*))?/g
, digitRe = /^\s*\d+/
, unescapeRe = /{\\/g
S.format = function(data) {
S.format = function(data, recursions) {
var args = typeof data == "object" ? data : arguments
return this.replace(formatRe, function(_, arg, filter) {
if (filter) {
var fn = "(_['"+arg+"']||''" + filter.replace(filterRe, ").$1($2") + ")"
return Fn(fn)(args).format(data)
}
return arg in args ? args[arg] : ""
}).replace(/{\\/g,"{")
return this.replace(formatRe, function(_, arg) {
_ = Fn(arg.replace(digitRe, "_[$&]").replace(filterRe, ".$1($2)"), "_")(args)
return args === data && recursions ? _.format(data, recursions - 1) : _
}).replace(unescapeRe, "{")
}
N.format = function(data, recursions) {
return ("" + this).format(data, recursions)
}
S.safe = function() {

@@ -1092,3 +1050,3 @@ return this

/*/
// High porformance replace when we should need it
// High porformance repeat when we should need it
// http://stackoverflow.com/questions/202605/repeat-string-javascript

@@ -1189,3 +1147,3 @@

},{}],7:[function(require,module,exports){
},{}],6:[function(require,module,exports){
(function (process){

@@ -1196,4 +1154,4 @@

/*
* @version 0.1.6
* @date 2014-03-11
* @version 0.1.8
* @date 2014-05-21
* @stability 2 - Unstable

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

, reset = '\u001b[0m'
function This() {

@@ -1353,2 +1311,3 @@ return this

, failed = 0
, passed_asserts = 0
, failed_asserts = 0

@@ -1361,2 +1320,3 @@ , ended = +new Date()

failed_asserts += assert.failed.length
passed_asserts += assert.passed.length
}

@@ -1366,5 +1326,11 @@ count += test.cases.length

console.log("1.." + count)
console.log("#" + (failed ? "" : green + bold) + " pass " + (count - failed) + reset)
console.log("# executed in " + (ended - started) + " ms")
failed && console.log("#" + red + bold + " fail " + failed + reset)
console.log("#" + (failed ? "" : green + bold) + " pass " + (count - failed)
+ "/" + count
+ " [" + passed_asserts + "/" +(passed_asserts + failed_asserts)+ "]"
+ " in " + (ended - started) + " ms"
+ reset)
failed && console.log("#" + red + bold + " fail " + failed
+ " [" +failed_asserts+ "]"
+ reset)
/*

@@ -1375,2 +1341,3 @@ * FAILED tests 1, 3, 6

*/
if (typeof process != "undefined" && process.exit) process.exit()
}

@@ -1395,3 +1362,3 @@ }

it.prototype = {
it.prototype = describe.asserts = {
describe: function(){

@@ -1450,3 +1417,3 @@ this.end()

" [" + (this.passed.length) + "/" + (this.passed.length+fail) + "]" + fail_log
}

@@ -1465,20 +1432,20 @@ }

}).call(this,require("/usr/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
},{"/usr/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":9}],8:[function(require,module,exports){
},{"/usr/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":8}],7:[function(require,module,exports){
(function (global){
require("browser-upgrade-lite")
global.Event = global.Event || {}
global.i18n = require("../i18n.js").i18n
global.i18n = require("../lib/i18n.js").i18n
global.Fn = require("functional-lite").Fn
require("browser-upgrade-lite")
require("liquid-filters-lite")
require("functional-lite")
require("../")
require("../haml")
function getString(node) {
if ('outerHTML' in node)
return node.outerHTML.toLowerCase().replace(/>[\n\r]+</g, "><").trim();
return node.outerHTML.toLowerCase().replace(/>[\n\r]+</g, "><").trim()
var div = document.createElement("div");
div.appendChild(node.cloneNode(true));
return div.innerHTML;
var div = document.createElement("div")
div.appendChild(node.cloneNode(true))
return div.innerHTML
}

@@ -1488,3 +1455,3 @@

var el, h1, h2, h3, h4, select, t1
var el, h1, h2, h3, h4, input, select, t1

@@ -1498,2 +1465,3 @@ require("testman").

select = El("select#id2.cl2:disabled")
input = El("input")
h1 = El("h1")

@@ -1560,11 +1528,11 @@ h2 = El("h2")

it ("shoult set attributes").
equal(select.set({title:"set title"}), select).
equal(select.title, "set title").
equal(select.set({title:"change title", name:"new name"}), select).
equal(select.title, "change title").
equal(select.name, "new name").
equal(select.set({title: null}), select).
equal(select.set({name: null}), select).
ok(!select.title).
ok(!select.name).
equal(input.set({id: "set_id", title:"set title"}), input).
equal(input.id, "set_id").
equal(input.title, "set title").
equal(input.set({title:"change title", name:"new name", id: "new_id"}), input).
equal(input.title, "change title").
equal(input.name, "new name").
equal(input.id, "new_id").
equal(input.set({title: null}), input).
ok(!input.title).

@@ -1675,10 +1643,10 @@ it ("has kill() and empty() methods").

describe( "Haml" ).
it ("supports haml").
equal(getString(El.haml("a\n b\n i")), '<a><b><i></i></b></a>').
equal(getString(El.haml("a \n b\n i")), '<a><b><i></i></b></a>').
equal(getString(El.haml("a\n b\n i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.haml("a\n b \n i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.haml("a\n b\n i link>to")), '<a><b><i>link&gt;to</i></b></a>').
anyOf(getString(El.haml("a[href='#a>b']\n b.bold \n i#ital link")),
describe( "Templates" ).
it ("supports tpl").
equal(getString(El.tpl("a\n b\n i")), '<a><b><i></i></b></a>').
equal(getString(El.tpl("a \n b\n i")), '<a><b><i></i></b></a>').
equal(getString(El.tpl("a\n b\n i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.tpl("a\n b \n i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.tpl("a\n b\n i link>to")), '<a><b><i>link&gt;to</i></b></a>').
anyOf(getString(El.tpl("a[href='#a>b']\n b.bold \n i#ital link")),
[ '<a href="#a>b"><b class=bold><i id=ital>link</i></b></a>'

@@ -1691,8 +1659,8 @@ , '<a href="#a>b"><b class="bold"><i id="ital">link</i></b></a>'

it ("supports block expansion").
equal(getString(El.haml("a>b>i")), '<a><b><i></i></b></a>').
equal(getString(El.haml("a > b>i")), '<a><b><i></i></b></a>').
equal(getString(El.haml("a>b>i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.haml("a>b > i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.haml("a>b>i link>to")), '<a><b><i>link&gt;to</i></b></a>').
anyOf(getString(El.haml("a[href='#a>b']>b.bold > i#ital link")),
equal(getString(El.tpl("a>b>i")), '<a><b><i></i></b></a>').
equal(getString(El.tpl("a > b>i")), '<a><b><i></i></b></a>').
equal(getString(El.tpl("a>b>i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.tpl("a>b > i link")), '<a><b><i>link</i></b></a>').
equal(getString(El.tpl("a>b>i link>to")), '<a><b><i>link&gt;to</i></b></a>').
anyOf(getString(El.tpl("a[href='#a>b']>b.bold > i#ital link")),
[ '<a href="#a>b"><b class=bold><i id=ital>link</i></b></a>'

@@ -1705,11 +1673,11 @@ , '<a href="#a>b"><b class="bold"><i id="ital">link</i></b></a>'

it ("supports templates").
anyOf(getString(El.haml(":template t1\n .temp1 t123\nt1")),
anyOf(getString(El.tpl(":template t1\n .temp1 t123\nt1")),
[ '<div class=temp1>t123</div>'
, '<div class="temp1">t123</div>'
]).
anyOf(getString(El.haml(":template t2\n .temp2>b t123\nt2")),
anyOf(getString(El.tpl(":template t2\n .temp2>b t123\nt2")),
[ '<div class=temp2><b>t123</b></div>'
, '<div class="temp2"><b>t123</b></div>'
]).
anyOf(getString(El.haml(":template t3\n .temp3\n b t123\nt3")),
anyOf(getString(El.tpl(":template t3\n .temp3\n b t123\nt3")),
[ '<div class=temp3><b>t123</b></div>'

@@ -1720,6 +1688,17 @@ , '<div class="temp3"><b>t123</b></div>'

it ( "should render data to elements" ).
equal(getString(t1 = El.haml("a>b>i =text:hello {name}")), '<a><b><i data-bind="text:hello {name}"></i></b></a>').
equal(getString(t1.render({name:"world"})), '<a><b><i data-bind="text:hello {name}">hello world</i></b></a>').
equal(getString(t1.render({name:"moon"})), '<a><b><i data-bind="text:hello {name}">hello moon</i></b></a>').
equal(getString(t1 = El.tpl("a>b[data-bind=\"class:'red','i>1'\"]>i =txt:'hello {name}'")), "<a><b data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\"></i></b></a>").
anyOf(getString(t1.render({i:1,name:"world"})),
[ "<a><b data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\">hello world</i></b></a>"
, "<a><b class=\"\" data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\">hello world</i></b></a>"
]).
anyOf(getString(t1.render({i:2,name:"moon"})),
[ "<a><b data-bind=\"class:'red','i>1'\" class=\"red\"><i data-bind=\"txt:'hello {name}'\">hello moon</i></b></a>"
, "<a><b class=\"red\" data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\">hello moon</i></b></a>"
]).
it ( "should show set DOM propperty when plugin not found" , {skip: "Browsers does not show attrs set by node.unknown_plugin = '123', should use node.set()"}).
equal(getString(t1 = El.tpl("a =unknown_plugin:\'hello {name}\'")), '<a data-bind="unknown_plugin:\'hello {name}\'"></a>').
equal(getString(t1.render({name:"world"})), '<a data-bind="unknown_plugin:\'hello {name}\'" unknown_plugin="hello world"></a>').
equal(getString(t1.render({name:"moon"})), '<a data-bind="unknown_plugin:\'hello {name}\'" unknown_plugin="hello moon"></a>').
done()

@@ -1808,3 +1787,3 @@

}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../":1,"../haml":2,"../i18n.js":3,"browser-upgrade-lite":4,"functional-lite":5,"liquid-filters-lite":6,"testman":7}],9:[function(require,module,exports){
},{"../":1,"../lib/i18n.js":2,"browser-upgrade-lite":3,"functional-lite":4,"liquid-filters-lite":5,"testman":6}],8:[function(require,module,exports){
// shim for using process in browser

@@ -1864,2 +1843,2 @@

},{}]},{},[8])
},{}]},{},[7])

@@ -0,7 +1,8 @@

require("browser-upgrade-lite")
global.Event = global.Event || {}
global.i18n = require("../lib/i18n.js").i18n
global.Fn = require("functional-lite").Fn
require("browser-upgrade-lite")
require("liquid-filters-lite")
require("functional-lite")
require("../")

@@ -11,7 +12,7 @@

if ('outerHTML' in node)
return node.outerHTML.toLowerCase().replace(/>[\n\r]+</g, "><").trim();
return node.outerHTML.toLowerCase().replace(/>[\n\r]+</g, "><").trim()
var div = document.createElement("div");
div.appendChild(node.cloneNode(true));
return div.innerHTML;
var div = document.createElement("div")
div.appendChild(node.cloneNode(true))
return div.innerHTML
}

@@ -249,6 +250,12 @@

equal(getString(t1 = El.tpl("a>b[data-bind=\"class:'red','i>1'\"]>i =txt:'hello {name}'")), "<a><b data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\"></i></b></a>").
equal(getString(t1.render({i:1,name:"world"})), "<a><b data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\">hello world</i></b></a>").
equal(getString(t1.render({i:2,name:"moon"})), "<a><b data-bind=\"class:'red','i>1'\" class=\"red\"><i data-bind=\"txt:'hello {name}'\">hello moon</i></b></a>").
anyOf(getString(t1.render({i:1,name:"world"})),
[ "<a><b data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\">hello world</i></b></a>"
, "<a><b class=\"\" data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\">hello world</i></b></a>"
]).
anyOf(getString(t1.render({i:2,name:"moon"})),
[ "<a><b data-bind=\"class:'red','i>1'\" class=\"red\"><i data-bind=\"txt:'hello {name}'\">hello moon</i></b></a>"
, "<a><b class=\"red\" data-bind=\"class:'red','i>1'\"><i data-bind=\"txt:'hello {name}'\">hello moon</i></b></a>"
]).
it ( "should show set DOM propperty when plugin not found" ).
it ( "should show set DOM propperty when plugin not found" , {skip: "Browsers does not show attrs set by node.unknown_plugin = '123', should use node.set()"}).
equal(getString(t1 = El.tpl("a =unknown_plugin:\'hello {name}\'")), '<a data-bind="unknown_plugin:\'hello {name}\'"></a>').

@@ -255,0 +262,0 @@ equal(getString(t1.render({name:"world"})), '<a data-bind="unknown_plugin:\'hello {name}\'" unknown_plugin="hello world"></a>').

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